How to plot two plotyy plots in the same plot

조회 수: 6 (최근 30일)
Benjamin
Benjamin 2011년 8월 15일
답변: Nir Dahan 2015년 8월 25일
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일
[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
Benjamin
Benjamin 2011년 8월 15일
Phenomenal, thanks!:)
Rajeev Yadav
Rajeev Yadav 2015년 6월 5일
doesnt work

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

추가 답변 (2개)

the cyclist
the cyclist 2011년 8월 15일
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
Rajeev Yadav
Rajeev Yadav 2015년 6월 5일
i tried this but it doesnt work in 2015a
Soroush
Soroush 2015년 7월 17일
Thanks!

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


Nir Dahan
Nir Dahan 2015년 8월 25일
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,...])

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by