I would like to know the syntax for plotting two y axes and single x axis for multiple line plots..

2 views (last 30 days)
Hai,
I would like to know the syntax for plotting two y axes and single x axis for multiple line plots..
e.g. my data were
x1=[0 2 4 6]
x2=[0 2 4 6 810]
x3=[0 2 4 6 8 10 12]
y1=[70 80 90 100]
y2=[85 95 100 105 110 112]
y3=[95 96 98 110 115 119 120]
yy1=[0.2 0.4 0.6 0.8]
yy2=[0.3 0.4 0.6 0.8 1.1 1.2]
yy3=[0.5 0.6 0.7 0.9 1.2 1.6 1.7]
Here, I want to plot y1vs x1, y2 vs x2,y3 vs x3 and yy1 vs x1, yy2 vs x2, yy3 vs x3 as a dual Y axes plots..
Can you guide me to plot these in matlab?
Thanks,

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 19 Jul 2013
ax1=axes('color','none','YAxisLocation','left')
ax2=axes('color','none','YAxisLocation','right')
plot(x3,y3,'b',x2,y2,'b',x1,y1,'b','parent',ax1)
hold on
plot(x3,yy3,'g',x2,yy2,'g',x1,yy1,'g','parent',ax2)

More Answers (2)

David Sanchez
David Sanchez on 19 Jul 2013
x1=[0 2 4 6];
x2=[0 2 4 6 8 10];
x3=[0 2 4 6 8 10 12];
y1=[70 80 90 100];
y2=[85 95 100 105 110 112];
y3=[95 96 98 110 115 119 120];
yy1=[0.2 0.4 0.6 0.8];
yy2=[0.3 0.4 0.6 0.8 1.1 1.2];
yy3=[0.5 0.6 0.7 0.9 1.2 1.6 1.7];
plotyy(x1, y1,x2,y2)
hold on
plot(x3,y3,x1,yy1,x2,yy2,x3,yy3)
hold off

Sabarunisha
Sabarunisha on 22 Jul 2013
Thank you Azzi Abdelmalek for your answer

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!