필터 지우기
필터 지우기

Trying to plot more than two graphs with two different scales onto a single plot

조회 수: 6 (최근 30일)
I would like to show the graphs of several signals from a group and a reference signal which has a completely different scale. I can use;
[ax,p1,p2]=plotyy(load(:,1),load(:,2),data(:,1),data(:,2))
the commonality between load and data is time
so, ylabel(ax(2),'Hits') ylabel(ax(1),'Displacement (in)') xlabel(ax(2),'Time (sec)')
and it works at showing two plots with two scales but I want to show more than these two plots but with the same two scales. It would greatly help reduce the number of graphs in my report and make more sense as a reader.
Any suggestions?
Thanks for your help

채택된 답변

Joseph Cheng
Joseph Cheng 2015년 3월 2일
you can use hold on to keep adding to these plots
x = 1:10 %time
for i =1:3
y(i,:)=1*x+i;
z(i,:)=2*x.^2+100+i;
end
[ax h1 h2]=plotyy(x,y(1,:),x,z(1,:));
ylabel(ax(2),'Hits');
ylabel(ax(1),'Displacement (in)');
xlabel(ax(2),'Time (sec)')
hold(ax(1),'on');
hold(ax(2),'on');
plot(ax(1),x,y(2,:))
plot(ax(2),x,z(2,:))
plot(ax(1),x,y(3,:))
plot(ax(2),x,z(3,:))
not the cleanest example but it shows how to add to existing and when run that everything stacks appropriately.

추가 답변 (1개)

ALEX
ALEX 2015년 3월 2일
Very interesting...my likey
I didn't realize you could plot multiple plots that way. This is game changer for me.
Thanks for your help!

카테고리

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