Help with multiple plots and axis

조회 수: 1 (최근 30일)
AVP
AVP 2014년 10월 14일
댓글: AVP 2014년 10월 15일
Hi,
I'm trying to find information on how to plot 5 different plots on the same plot, but using the left y-axis for 2 of them and the right y-axis for 3 of them. They are very different in scale and so I need them to be overlapped but tied to different scales. I've seen quite a few videos and forum posts on how to do multiple graphs OR multiple axis but I haven't seen anything on doing both at the same time. I've tried combining both but I keep getting errors. Any help is greatly appreciated.
Thanks.

답변 (1개)

Andrew Bliss
Andrew Bliss 2014년 10월 15일
Something like this might work:
figure
ax(1)=axes; hold on
ax(2)=axes; hold on
set(ax(2),'YAxisLocation','right','color','none','xcolor','r','ycolor','r')
plot(ax(1),1:10,rand(1,10))
plot(ax(1),1:10,.3*rand(1,10),'.')
plot(ax(1),1:10,.6*rand(1,10),'+')
plot(ax(2),1:10,50*rand(1,10),'r')
  댓글 수: 1
AVP
AVP 2014년 10월 15일
That got me closer but the plot(ax(1),1:10,rand(1,10))doesn't work because it's trying to plot against the value of the axis.
The issue I keep having is that setting the second axis deletes the plot that I did on the first axis.
This gets me the closest but it puts all of them on the second axis: figure ax(1)=axes; hold on; ax(2)=axes; hold on; line(T,LVDT,'Color','r') line(T,SyncLock,'Color','b')
set(ax(2),'YAxisLocation','right')
line(T,PSIGstow,'Color','y') line(T,PSIGdeploy,'Color','g') line(T,LoadCell,'Color','c')

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by