how to draw two y axis?

2 ビュー (過去 30 日間)
Ibrahim AlZoubi
Ibrahim AlZoubi 2020 年 6 月 16 日
回答済み: Deepak Gupta 2020 年 6 月 16 日
I've two lines:
x=[0,0,0,0,0,76,344,607,748,816,840,850,841,835,773,661,435,169,0,0,0,0,0,0];
z=[4.8,4.4,4.1,4.4,4.8,5.1,7.2,7.2,7.2,7.2,7.2,6.2,5.1,6.2,6.2,8.2,8.2,7.2,7.2,5.1,4.1,5.1,9.3,8.2];
months_of_the_year=0:1:23;
plot(months_of_the_year,x,'-',months_of_the_year,z,'--','LineWidth',2.5)
when I plot them the porblem is one of these lines is not visable, how can i draw two y axis which makes me see the second line?
how to make each of these two y axis for each line?
  1 件のコメント
Deepak Gupta
Deepak Gupta 2020 年 6 月 16 日
Can you clarify, what do you mean by two Y axis? Are you referring variable z as second Y axis?

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

採用された回答

Deepak Gupta
Deepak Gupta 2020 年 6 月 16 日
As suggested by Madhan, you can use yyaxis function to show 2 different scales on yaxis.
In your case,
x=[0,0,0,0,0,76,344,607,748,816,840,850,841,835,773,661,435,169,0,0,0,0,0,0];
z=[4.8,4.4,4.1,4.4,4.8,5.1,7.2,7.2,7.2,7.2,7.2,6.2,5.1,6.2,6.2,8.2,8.2,7.2,7.2,5.1,4.1,5.1,9.3,8.2];
months_of_the_year=0:1:23;
yyaxis left
plot(months_of_the_year,x,'-')
yyaxis right
plot(months_of_the_year,z,'--','LineWidth',2.5)

その他の回答 (1 件)

madhan ravi
madhan ravi 2020 年 6 月 16 日

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by