how to spesify left y axis as follow:
(0 500 1000)

1 件のコメント

Ibrahim AlZoubi
Ibrahim AlZoubi 2020 年 6 月 21 日
I use ylim([1 1000])

サインインしてコメントする。

 採用された回答

the cyclist
the cyclist 2020 年 6 月 21 日
編集済み: the cyclist 2020 年 6 月 21 日

0 投票

Try this:
clear
clc
clf
x=1:1:24
yyaxis right
y =[0,0,0,0,0,2.879097736,22.91004173,45.42868867,58.31916249,64,65,66,65,64,60,53.00046608,32.17312477,9.879732541,0,0,0,0,0,0];
plot(x,y,'k','LineWidth',2.5)
yyaxis left
z=[242.5325006,242.5325006,242.5325006,242.5325006,0,13.29108368,66.80670854,139.455836,196.175253,215.5559079,218.7020474,220.3220205,218.7020474,215.5559079,196.175253,139.455836,66.80670854,13.29108368,0,242.5325006,242.5325006,242.5325006,242.5325006,242.5325006];
n=[0,0,0,0,0,76,344,607,748,816,840,850,841,835,773,661,435,169,0,0,0,0,0,0]
plot(x,n,'b',x,z,'b','LineWidth',2.5)
set(gca,'YLim',[0 1000],'YTick',[0 500 1000],'YTickLabel',[0 500 1000])
I forced the limit of the left-hand y-axis to be [0 1000], so that the ticks show up.

1 件のコメント

Ibrahim AlZoubi
Ibrahim AlZoubi 2020 年 6 月 21 日
you're amazing thank you so much!

サインインしてコメントする。

その他の回答 (1 件)

the cyclist
the cyclist 2020 年 6 月 21 日

1 投票

set(gca,'YTick',[0 500 1000],'YTickLabel',[0 500 1000])

5 件のコメント

Ibrahim AlZoubi
Ibrahim AlZoubi 2020 年 6 月 21 日
Not working
the cyclist
the cyclist 2020 年 6 月 21 日
編集済み: the cyclist 2020 年 6 月 21 日
Here is a simple example that shows that this syntax works:
figure
plot(1000*rand(7))
set(gca,'YTick',[0 500 1000],'YTickLabel',[0 500 1000])
Perhaps you are doing something afterward that changes it? Maybe you could post the code that creates your figure.
Here is a link to the documentation that explains what I did.
Ibrahim AlZoubi
Ibrahim AlZoubi 2020 年 6 月 21 日
what is rand 7
Ibrahim AlZoubi
Ibrahim AlZoubi 2020 年 6 月 21 日
clear
clc
clf
x=1:1:24
yyaxis right
y =[0,0,0,0,0,2.879097736,22.91004173,45.42868867,58.31916249,64,65,66,65,64,60,53.00046608,32.17312477,9.879732541,0,0,0,0,0,0];
plot(x,y,'k','LineWidth',2.5)
yyaxis left
z=[242.5325006,242.5325006,242.5325006,242.5325006,0,13.29108368,66.80670854,139.455836,196.175253,215.5559079,218.7020474,220.3220205,218.7020474,215.5559079,196.175253,139.455836,66.80670854,13.29108368,0,242.5325006,242.5325006,242.5325006,242.5325006,242.5325006];
n=[0,0,0,0,0,76,344,607,748,816,840,850,841,835,773,661,435,169,0,0,0,0,0,0]
plot(x,n,'b',x,z,'b','LineWidth',2.5)
this's my code
the cyclist
the cyclist 2020 年 6 月 21 日
rand(7)
was just me generating some random numbers to plot, to illustrate that my code suggestion worked in that case.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by