choose the limit of two y axes

2 ビュー (過去 30 日間)
SYML2nd
SYML2nd 2022 年 8 月 3 日
コメント済み: KSSV 2022 年 8 月 3 日
I would like to do a graph with two y axes. I have found this. I have two questions that have no answer here:
1.how to have the two axes simply in black and not in blu and orange (very strange default choice).
2.How can I choose the limit of each axes? I usually use ylim([]), but now how can I choose the right or left axis?
Thank you

回答 (1 件)

KSSV
KSSV 2022 年 8 月 3 日
編集済み: KSSV 2022 年 8 月 3 日
x = linspace(0,25);
y = sin(x/2);
yyaxis left ;
plot(x,y,'k');
ax(1) = gca ;
r = x.^2/2;
yyaxis right
plot(x,r);
ax(2) = gca ;
% change axis colors
ax(1).YColor = 'g' ;
ax(2).YColor = 'm' ;
ax(1).YLim % set your value here
ans = 1×2
0 350
ax(2).YLim % set your value here
ans = 1×2
0 350
  4 件のコメント
SYML2nd
SYML2nd 2022 年 8 月 3 日
Ok. thank you @KSSV. I obtained the two axes in black, but how to choose their limits now? Furthermore I also would like to choose every tick of the axis
KSSV
KSSV 2022 年 8 月 3 日
Try using ylim after the plot twice.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by