How to plot two plotyy plots in the same plot

I am trying to plot four plots in the same figure. First i plot using plotyy. Then two graphs are created, each with a yaxis.
Now I want to plot another two plots. One using yaxis-1 and one using yaxis-2. How do i do this?
If I do
[ax,h1,h2] = plotyy(...)
hold on
plot(ax(1),...)
plot(ax(2),...)
i don't get all four plots.
Thanks :)
Ben

댓글 수: 1

Benjamin
Benjamin 2011년 8월 15일
I mean:
[ax,h1,h2] = plotyy(...)
hold on
plot(ax(1),...)
plot(ax(2),...)

댓글을 달려면 로그인하십시오.

 채택된 답변

Paulo Silva
Paulo Silva 2011년 8월 15일

0 개 추천

[ax,h1,h2] = plotyy(...)
hold(ax(1))
plot(ax(1),...)
hold(ax(2))
plot(ax(2),...)
The problem was simple, hold on just holds the current axes and your plotyy makes two axes so only one is the current.

추가 답변 (2개)

the cyclist
the cyclist 2011년 8월 15일

4 개 추천

figure
[hax12 line1 hline2] = plotyy(1:10,1:10,1:10,2:11)
set(hax12,'NextPlot','add')
plot(hax12(1),1:10,3:12)
plot(hax12(2),1:10,4:13)

댓글 수: 5

Benjamin
Benjamin 2011년 8월 15일
Great, thanks a lot! :)
Thank you....
Paulo F.
Paulo F. 2014년 9월 27일
Thanks, this saved me a second day of trials!
i tried this but it doesnt work in 2015a
Soroush
Soroush 2015년 7월 17일
Thanks!

댓글을 달려면 로그인하십시오.

Nir Dahan
Nir Dahan 2015년 8월 25일

0 개 추천

try this one where all vectors are column, of size (N,1)
[ax,h1,h2]=plotyy([x,x,x,...],[y1,y2,y3,...],[X,X,X,...],[Y1,Y2,Y3,...])

카테고리

도움말 센터File Exchange에서 Two y-axis에 대해 자세히 알아보기

질문:

2011년 8월 15일

답변:

2015년 8월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by