how to plot Double y axis?

This value how plot in matlab R2015 version?
Distance (X axis) TIFF (y1) Percentage (y2)
Fixed Float
1 2 99 1
6 6 97 3
10 8 94 6
15 10 92 8
22 15 89 11

回答 (3 件)

Yusuf Suer Erdem
Yusuf Suer Erdem 2021 年 11 月 11 日

0 投票

x = linspace(0,10);
y = sin(x);
yyaxis left
plot(x,y)
z = (8*x);
yyaxis right
plot(x,z)
ylim([-150 150])
I put an example above. The x axis is singular. And we have two Y axis. The limit of Y axis is [-150,150]. I hope it helps!

3 件のコメント

SOMNATH MAHATO
SOMNATH MAHATO 2021 年 11 月 11 日
Thank you for your responce. But i have three axis, how i plot it in y double axis?
x = [1 6 10 15 22]; (Distance)
y1 = [2 6 8 10 15]; (TIFF)
y2 = [99 97 94 92 89]; (Percentage)
y3= [1 3 6 8 11]; (Percentage)
Yusuf Suer Erdem
Yusuf Suer Erdem 2021 年 11 月 11 日
Just try the way below and it will work for you:
x = [1 6 10 15 22];
y1 = [2 6 8 10 15];
y2 = [99 97 94 92 89];
y3= [1 3 6 8 11];
plot(x,y1,x,y2,x,y3)
Adam Danz
Adam Danz 2021 年 11 月 11 日

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

Awais Saeed
Awais Saeed 2021 年 11 月 11 日

0 投票

For version 2016a aor later, use yyaxis instead
x = [1 6 10 15 22];
y1 = [2 6 8 10 15];
y2 = [99 97 94 92 89];
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
ylabel(hAx(1),'TIFF') % left y-axis
ylabel(hAx(2),'Percentage') % right y-axis

5 件のコメント

SOMNATH MAHATO
SOMNATH MAHATO 2021 年 11 月 11 日
Thank you for your answer. But Y axis have 3 line.
x = [1 6 10 15 22]; (Distance)
y1 = [2 6 8 10 15]; (TIFF)
y2 = [99 97 94 92 89]; (Percentage)
y3= [1 3 6 8 11]; (Percentage)
Kindly provide the code of this. Thank you in advance.
Awais Saeed
Awais Saeed 2021 年 11 月 11 日
You might need a function from file exchange. Have a look at this.
SOMNATH MAHATO
SOMNATH MAHATO 2021 年 11 月 11 日
I have tried many times but shows errors. can you try it for me, if possible?
SOMNATH MAHATO
SOMNATH MAHATO 2022 年 4 月 21 日
I can't change right y axis color. How i can change it?
Adam Danz
Adam Danz 2022 年 4 月 22 日
> I can't change right y axis color. How i can change it?
yyaxis right
ax = gca();
ax.YAxis(2).Color = 'r';

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

SOMNATH MAHATO
SOMNATH MAHATO 2022 年 4 月 22 日

0 投票

Below this this code y axis right side color not change. Have a look with this code.
x = [1 6 10 15 ];
y1 = [1 2 2 2 ];
y2 = [100 99.99 89.73 78.22];
figure('Color','w')
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
xlabel ('Distance (km)')
ylabel(hAx(1),'TFFS (s)') % left y-axis
ylabel(hAx(2),'Fix solution Percentage (%)') % right y-axis
grid on
yyaxis right
ax = gca();
ax.YAxis(2).Color = 'r';

カテゴリ

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

質問済み:

2021 年 11 月 11 日

回答済み:

2022 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by