modify a certain section of the axis while keeping the rest
1 次查看(过去 30 天)
显示 更早的评论
JL
2019-8-18
Hi everyone, I'm produced this plot using this codes
figure
z1 = stairs(x1, y1, 'LineWidth',1)
hold on;
z2 = stairs(x2, y2, 'LineWidth',1)
hold on;
z3 = stairs(x3, y3, 'LineWidth',1)
hold on;
z4 = stairs(x4, y4, 'LineWidth',1)
grid
I'm wondering if its possible to keep the axis between 0.975 to 0.995 then modify the spacing between 0.995 to 1 (as indicated by the red box) to show certain values such 0.99757953, 0.99758321, 0.99758452, 0.99758671, 0.99905220, 0.99992986, 0.99993039, 0.99993380, 0.99993599, 0.99993730,0.99993861 which are lumped into a line (i'm sure there are also in stairs but can't see from this graph)
采纳的回答
KALYAN ACHARJYA
2019-8-18
编辑:KALYAN ACHARJYA
2019-8-18
Try this one?
x1=..;
y1=..:
so on .....x2,y2,x3,y3....
figure, z1 = stairs(x1, y1, 'LineWidth',1)
hold on;
z2 = stairs(x2, y2, 'LineWidth',1)
z3 = stairs(x3, y3, 'LineWidth',1)
z4 = stairs(x4, y4, 'LineWidth',1)
xlim([0.975 0.995]);
xticks([%..decide tick level....]);
grid on;
xticks detail
15 个评论
JL
2019-8-18
I tried putting in these numbers 0.99757953, 0.99758321, 0.99758452, 0.99758671, 0.99905220, 0.99992986, 0.99993039, 0.99993380, 0.99993599, 0.99993730,0.99993861 but i got error :(
JL
2019-8-18
y1=[
248.6983;240.415;230.9749;230.9739;226.1955;226.1953;226.1951;217.611;214.5441;
214.5438;214.5436;214.5435;214.5432;214.5431;214.5423;210.3631;178.7871;178.7869;
178.7868;178.7867;178.7865;178.7863;178.7861;178.7859;178.7858;178.7856;178.7855;
178.7854;178.7853;178.7851;178.7844;178.7841;178.7838;161.5685;155.4362;153.9838;
153.9836;153.9819;153.9807;153.9804;150.2594;150.2593;150.2592;143.029;143.0287;
143.0285;143.0281;143.0271;135.267;135.2654;135.2651;129.2546;129.2544;129.2542;129.254;
129.2539;129.2538;129.2537;129.2536;129.2533;124.3491;124.349;124.3489;120.2074;
107.2718;107.2716;107.2712;107.2703;107.2702;95.0318;90.9706;0;];
x1 =[
0.979192;0.980597;0.980597;0.981426;0.982325;0.982327;
0.982327;0.982327;0.982328;0.982332;0.982339;0.982341;0.982342;0.982344;
0.983805;0.985332;0.985335;0.987363;0.987365;0.987367;0.987367;0.987371;
0.989126;0.989133;0.989137;0.989142;0.989143;0.989146;0.989152;0.989153;
0.989155;0.989158;0.990932;0.990933;0.990933;0.990936;0.99094;0.991763;
0.991765;0.992638;0.992642;0.992643;0.992643;0.992644;0.992645;0.992646;
0.992646;0.992647;0.993509;0.993509;0.993513;0.99352;0.993521;0.993522;
0.994412;0.995286;0.995292;0.995871;0.995875;0.997343;0.997345;0.997347;
0.997349;0.99854;0.998541;0.998542;0.998544;0.998546;0.998556;0.999999;
0.999999;1;];
x2 =[
0.981352282533856;0.984573892615804;0.984575204755339;0.984576516894873;
0.984577829034407;0.985162765338026;0.985163289723456;0.98721546745641;
0.988972375791083;0.990144522826278;0.991608175332872;0.991609224730723;
0.991610274128574;0.991611849166961;0.992489515815104;0.992501502483707;
0.994262090306082;0.994264716939883;0.994267869843182;0.994270496476983;
0.994272597155907;0.995152101898602;0.995153414038136;0.996033967864201;
0.99603501757611;0.996039216893566;0.996040003706762;0.997506017750741;
0.997508379602325;0.997512316020928;0.997513102834124;0.997513977332489;
0.997514764145686;0.997518443633387;0.997520193675727;0.997523258998654;
0.99752632432158;0.997528162416132;0.997530350623149;0.997531662762683;
0.997536738933237;0.997542078159485;0.997543127557336;0.997546277634111;
0.997546279988843;0.99754706680204;0.997547853615236;0.997548640428432;
0.99755082863545;0.997552140774984;0.997554328982001;0.999023673445322;
0.999026300079123;0.999027612218658;0.999032337491131;0.999035748583396;
0.999037322209789;0.999038371607639;0.999039158420836;0.999039945234032;
0.999917611882175;0.99992242436826;0.999923736507795;0.99992461100616;
0.999926186044547;0.999927761082935;0.999930387716736;0.999931174529932;
0.999933798809001;0.999935110948535;0.999937299155552;0.999938611295086;];
y2 = [
248.6983;248.6982;248.6981;248.698;248.6979;248.6978;248.6977;248.6976;248.6975;
248.6974;248.6973;248.6971;248.6968;248.6794;245.3628;245.3619;245.3616;245.3614;
245.361;245.3608;245.3607;245.3605;245.3603;245.36;245.3589;245.3585;243.2405;
243.2403;243.2402;243.24;243.2397;243.2396;243.2394;243.2393;243.2392;243.2391;
243.2389;243.2388;243.2385;241.3514;241.3508;240.415;240.4149;238.0196;233.2508;
193.0819;190.0636;0;];
x3 =[
0.981222;0.981237;0.982997;0.983834;0.983844;0.983847;0.98385;
0.984734;0.984736;0.98561;0.987384;0.987384;0.987388;0.987391;0.988859;
0.988863;0.989442;0.989442;0.989446;0.989449;0.98945;0.99151;0.991514;
0.991522;0.991523;0.992346;0.992346;0.992353;0.992355;0.992357;0.992371;
0.992372;0.992374;0.994756;0.994756;0.99476;0.996168;0.996173;0.996176;
0.996176;0.996176;0.998542;0.998544;0.998544;0.998556;0.998556;
0.999999;1;];
x4 =[
0.984294121851755;0.987528252196561;0.988416505686633;0.988425170517728;
0.989896345696312;0.989904742919229;0.989906316545621;0.989907628685155;
0.989909816892173;0.989911915844903;0.989912702658099;0.98991375205595;
0.989915940262967;0.989916814761333;0.989917601574529;0.989918388387725;
0.989919437785576;0.989919962171006;0.989923375618003;0.989924162431199;
0.989925474570733;0.989927135882295;0.989928448021829;0.989932647967965;
0.989933960107499;0.989935798202051;0.989936672700416;0.989939646151512;
0.989942272785313;0.989943322497221;0.990828954062958;0.990830003460808;
0.990831052858659;0.992301095244459;0.992302407383993;0.993474554419188;
0.994941272248709;0.997579526719226;0.997583206206928;0.997584518346462;
0.99758670655348;0.999052196683163;0.999929863331306;0.999930387716736;
0.999933798809;0.999935987016018;0.999937299155552;0.999938611295086;];
figure
z1 = stairs(x1, y1, 'LineWidth',1)
hold on;
z2 = stairs(x2, y1, 'LineWidth',1)
hold on;
z3 = stairs(x3, y2, 'LineWidth',1)
hold on;
z4 = stairs(x4, y2, 'LineWidth',1)
grid
KALYAN ACHARJYA
2019-8-18
编辑:KALYAN ACHARJYA
2019-8-18
clc;
clear all;
close all;
y1=[
248.6983;240.415;230.9749;230.9739;226.1955;226.1953;226.1951;217.611;214.5441;
214.5438;214.5436;214.5435;214.5432;214.5431;214.5423;210.3631;178.7871;178.7869;
178.7868;178.7867;178.7865;178.7863;178.7861;178.7859;178.7858;178.7856;178.7855;
178.7854;178.7853;178.7851;178.7844;178.7841;178.7838;161.5685;155.4362;153.9838;
153.9836;153.9819;153.9807;153.9804;150.2594;150.2593;150.2592;143.029;143.0287;
143.0285;143.0281;143.0271;135.267;135.2654;135.2651;129.2546;129.2544;129.2542;129.254;
129.2539;129.2538;129.2537;129.2536;129.2533;124.3491;124.349;124.3489;120.2074;
107.2718;107.2716;107.2712;107.2703;107.2702;95.0318;90.9706;0;];
x1 =[
0.979192;0.980597;0.980597;0.981426;0.982325;0.982327;
0.982327;0.982327;0.982328;0.982332;0.982339;0.982341;0.982342;0.982344;
0.983805;0.985332;0.985335;0.987363;0.987365;0.987367;0.987367;0.987371;
0.989126;0.989133;0.989137;0.989142;0.989143;0.989146;0.989152;0.989153;
0.989155;0.989158;0.990932;0.990933;0.990933;0.990936;0.99094;0.991763;
0.991765;0.992638;0.992642;0.992643;0.992643;0.992644;0.992645;0.992646;
0.992646;0.992647;0.993509;0.993509;0.993513;0.99352;0.993521;0.993522;
0.994412;0.995286;0.995292;0.995871;0.995875;0.997343;0.997345;0.997347;
0.997349;0.99854;0.998541;0.998542;0.998544;0.998546;0.998556;0.999999;
0.999999;1;];
x2 =[
0.981352282533856;0.984573892615804;0.984575204755339;0.984576516894873;
0.984577829034407;0.985162765338026;0.985163289723456;0.98721546745641;
0.988972375791083;0.990144522826278;0.991608175332872;0.991609224730723;
0.991610274128574;0.991611849166961;0.992489515815104;0.992501502483707;
0.994262090306082;0.994264716939883;0.994267869843182;0.994270496476983;
0.994272597155907;0.995152101898602;0.995153414038136;0.996033967864201;
0.99603501757611;0.996039216893566;0.996040003706762;0.997506017750741;
0.997508379602325;0.997512316020928;0.997513102834124;0.997513977332489;
0.997514764145686;0.997518443633387;0.997520193675727;0.997523258998654;
0.99752632432158;0.997528162416132;0.997530350623149;0.997531662762683;
0.997536738933237;0.997542078159485;0.997543127557336;0.997546277634111;
0.997546279988843;0.99754706680204;0.997547853615236;0.997548640428432;
0.99755082863545;0.997552140774984;0.997554328982001;0.999023673445322;
0.999026300079123;0.999027612218658;0.999032337491131;0.999035748583396;
0.999037322209789;0.999038371607639;0.999039158420836;0.999039945234032;
0.999917611882175;0.99992242436826;0.999923736507795;0.99992461100616;
0.999926186044547;0.999927761082935;0.999930387716736;0.999931174529932;
0.999933798809001;0.999935110948535;0.999937299155552;0.999938611295086;];
y2 = [
248.6983;248.6982;248.6981;248.698;248.6979;248.6978;248.6977;248.6976;248.6975;
248.6974;248.6973;248.6971;248.6968;248.6794;245.3628;245.3619;245.3616;245.3614;
245.361;245.3608;245.3607;245.3605;245.3603;245.36;245.3589;245.3585;243.2405;
243.2403;243.2402;243.24;243.2397;243.2396;243.2394;243.2393;243.2392;243.2391;
243.2389;243.2388;243.2385;241.3514;241.3508;240.415;240.4149;238.0196;233.2508;
193.0819;190.0636;0;];
x3 =[
0.981222;0.981237;0.982997;0.983834;0.983844;0.983847;0.98385;
0.984734;0.984736;0.98561;0.987384;0.987384;0.987388;0.987391;0.988859;
0.988863;0.989442;0.989442;0.989446;0.989449;0.98945;0.99151;0.991514;
0.991522;0.991523;0.992346;0.992346;0.992353;0.992355;0.992357;0.992371;
0.992372;0.992374;0.994756;0.994756;0.99476;0.996168;0.996173;0.996176;
0.996176;0.996176;0.998542;0.998544;0.998544;0.998556;0.998556;
0.999999;1;];
x4 =[
0.984294121851755;0.987528252196561;0.988416505686633;0.988425170517728;
0.989896345696312;0.989904742919229;0.989906316545621;0.989907628685155;
0.989909816892173;0.989911915844903;0.989912702658099;0.98991375205595;
0.989915940262967;0.989916814761333;0.989917601574529;0.989918388387725;
0.989919437785576;0.989919962171006;0.989923375618003;0.989924162431199;
0.989925474570733;0.989927135882295;0.989928448021829;0.989932647967965;
0.989933960107499;0.989935798202051;0.989936672700416;0.989939646151512;
0.989942272785313;0.989943322497221;0.990828954062958;0.990830003460808;
0.990831052858659;0.992301095244459;0.992302407383993;0.993474554419188;
0.994941272248709;0.997579526719226;0.997583206206928;0.997584518346462;
0.99758670655348;0.999052196683163;0.999929863331306;0.999930387716736;
0.999933798809;0.999935987016018;0.999937299155552;0.999938611295086;];
figure
z1 = stairs(x1, y1, 'LineWidth',1)
hold on;
z2 = stairs(x2, y1, 'LineWidth',1)
z3 = stairs(x3, y2, 'LineWidth',1)
z4 = stairs(x4, y2, 'LineWidth',1);
xlim([0.975 0.995]);
xticks([0.975:.001:0.995]);
grid on;
You can set the tick levels as per your requirements ....see detail xticks documentation.
JL
2019-8-18
thank you but I actually want to modify those from 0.995 onwards because up to 1 while keeping 0.975 to 0.995. is it possible?
JL
2019-8-18
Hi Kalyan, I tried the amended code. I'm getting undefined function message. I dont see the same results as you got
KALYAN ACHARJYA
2019-8-18
编辑:KALYAN ACHARJYA
2019-8-18
Here again, changes xticks levels also
clc;
clear all;
close all;
y1=[
248.6983;240.415;230.9749;230.9739;226.1955;226.1953;226.1951;217.611;214.5441;
214.5438;214.5436;214.5435;214.5432;214.5431;214.5423;210.3631;178.7871;178.7869;
178.7868;178.7867;178.7865;178.7863;178.7861;178.7859;178.7858;178.7856;178.7855;
178.7854;178.7853;178.7851;178.7844;178.7841;178.7838;161.5685;155.4362;153.9838;
153.9836;153.9819;153.9807;153.9804;150.2594;150.2593;150.2592;143.029;143.0287;
143.0285;143.0281;143.0271;135.267;135.2654;135.2651;129.2546;129.2544;129.2542;129.254;
129.2539;129.2538;129.2537;129.2536;129.2533;124.3491;124.349;124.3489;120.2074;
107.2718;107.2716;107.2712;107.2703;107.2702;95.0318;90.9706;0;];
x1 =[
0.979192;0.980597;0.980597;0.981426;0.982325;0.982327;
0.982327;0.982327;0.982328;0.982332;0.982339;0.982341;0.982342;0.982344;
0.983805;0.985332;0.985335;0.987363;0.987365;0.987367;0.987367;0.987371;
0.989126;0.989133;0.989137;0.989142;0.989143;0.989146;0.989152;0.989153;
0.989155;0.989158;0.990932;0.990933;0.990933;0.990936;0.99094;0.991763;
0.991765;0.992638;0.992642;0.992643;0.992643;0.992644;0.992645;0.992646;
0.992646;0.992647;0.993509;0.993509;0.993513;0.99352;0.993521;0.993522;
0.994412;0.995286;0.995292;0.995871;0.995875;0.997343;0.997345;0.997347;
0.997349;0.99854;0.998541;0.998542;0.998544;0.998546;0.998556;0.999999;
0.999999;1;];
x2 =[
0.981352282533856;0.984573892615804;0.984575204755339;0.984576516894873;
0.984577829034407;0.985162765338026;0.985163289723456;0.98721546745641;
0.988972375791083;0.990144522826278;0.991608175332872;0.991609224730723;
0.991610274128574;0.991611849166961;0.992489515815104;0.992501502483707;
0.994262090306082;0.994264716939883;0.994267869843182;0.994270496476983;
0.994272597155907;0.995152101898602;0.995153414038136;0.996033967864201;
0.99603501757611;0.996039216893566;0.996040003706762;0.997506017750741;
0.997508379602325;0.997512316020928;0.997513102834124;0.997513977332489;
0.997514764145686;0.997518443633387;0.997520193675727;0.997523258998654;
0.99752632432158;0.997528162416132;0.997530350623149;0.997531662762683;
0.997536738933237;0.997542078159485;0.997543127557336;0.997546277634111;
0.997546279988843;0.99754706680204;0.997547853615236;0.997548640428432;
0.99755082863545;0.997552140774984;0.997554328982001;0.999023673445322;
0.999026300079123;0.999027612218658;0.999032337491131;0.999035748583396;
0.999037322209789;0.999038371607639;0.999039158420836;0.999039945234032;
0.999917611882175;0.99992242436826;0.999923736507795;0.99992461100616;
0.999926186044547;0.999927761082935;0.999930387716736;0.999931174529932;
0.999933798809001;0.999935110948535;0.999937299155552;0.999938611295086;];
y2 = [
248.6983;248.6982;248.6981;248.698;248.6979;248.6978;248.6977;248.6976;248.6975;
248.6974;248.6973;248.6971;248.6968;248.6794;245.3628;245.3619;245.3616;245.3614;
245.361;245.3608;245.3607;245.3605;245.3603;245.36;245.3589;245.3585;243.2405;
243.2403;243.2402;243.24;243.2397;243.2396;243.2394;243.2393;243.2392;243.2391;
243.2389;243.2388;243.2385;241.3514;241.3508;240.415;240.4149;238.0196;233.2508;
193.0819;190.0636;0;];
x3 =[
0.981222;0.981237;0.982997;0.983834;0.983844;0.983847;0.98385;
0.984734;0.984736;0.98561;0.987384;0.987384;0.987388;0.987391;0.988859;
0.988863;0.989442;0.989442;0.989446;0.989449;0.98945;0.99151;0.991514;
0.991522;0.991523;0.992346;0.992346;0.992353;0.992355;0.992357;0.992371;
0.992372;0.992374;0.994756;0.994756;0.99476;0.996168;0.996173;0.996176;
0.996176;0.996176;0.998542;0.998544;0.998544;0.998556;0.998556;
0.999999;1;];
x4 =[
0.984294121851755;0.987528252196561;0.988416505686633;0.988425170517728;
0.989896345696312;0.989904742919229;0.989906316545621;0.989907628685155;
0.989909816892173;0.989911915844903;0.989912702658099;0.98991375205595;
0.989915940262967;0.989916814761333;0.989917601574529;0.989918388387725;
0.989919437785576;0.989919962171006;0.989923375618003;0.989924162431199;
0.989925474570733;0.989927135882295;0.989928448021829;0.989932647967965;
0.989933960107499;0.989935798202051;0.989936672700416;0.989939646151512;
0.989942272785313;0.989943322497221;0.990828954062958;0.990830003460808;
0.990831052858659;0.992301095244459;0.992302407383993;0.993474554419188;
0.994941272248709;0.997579526719226;0.997583206206928;0.997584518346462;
0.99758670655348;0.999052196683163;0.999929863331306;0.999930387716736;
0.999933798809;0.999935987016018;0.999937299155552;0.999938611295086;];
figure
z1 = stairs(x1, y1, 'LineWidth',1)
hold on;
z2 = stairs(x2, y1, 'LineWidth',1)
z3 = stairs(x3, y2, 'LineWidth',1)
z4 = stairs(x4, y2, 'LineWidth',1);
xlim([0.975 0.995]);
xticklabels([0.975:.005:0.995]);
grid on;
Please change the xlim and xticks levels as per your requirements. Please ensure that the xticks levels must be withn the range of xlim.
Hope it helps!
KALYAN ACHARJYA
2019-8-18
编辑:KALYAN ACHARJYA
2019-8-18
Sorry, its xticklabels([0.975:.005:0.995]); try with
xticklabels(0.975:.005:0.995);
rest code is same
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Formatting and Annotation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)