how to plot Double y axis?

5 views (last 30 days)
SOMNATH MAHATO
SOMNATH MAHATO on 11 Nov 2021
Commented: Adam Danz on 11 Nov 2021
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

Answers (2)

Yusuf Suer Erdem
Yusuf Suer Erdem on 11 Nov 2021
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 Comments

Sign in to comment.


Awais Saeed
Awais Saeed on 11 Nov 2021
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
  3 Comments
SOMNATH MAHATO
SOMNATH MAHATO on 11 Nov 2021
I have tried many times but shows errors. can you try it for me, if possible?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!