필터 지우기
필터 지우기

How to put stacked plots in the same graph

조회 수: 2 (최근 30일)
Alan
Alan 2011년 11월 10일
Hi, I want to put eleven plots in the same graph but separately i. e. all them will be in same x axis but in different scales in the y axis. For example: first graphic starts in 0 value in y axis, second plot starts in 100 value in the y axis and so on. Thanks

채택된 답변

Jonathan
Jonathan 2011년 11월 10일
Alan,
To plot the data all in the same plot, do something like the following.
x1 = 0:.01:1;
y1 = x1.^2;
x2 = .5:.1:1;
y2 = -1*x2 + 10;
fHand1 = figure;
aHand1 = axes('parent', fHand1);
hold(aHand1, 'on')
plot(x1, y1, 'parent', aHand1);
plot(x2, y2, 'parent', aHand1);
To make the plots scale independent - so the min of the plot is at the bottom and the max is at the top - you need to normalize the y values before plotting. In this case, it helps to remove the y axis labels to avoid confusion. Here is how I did it.
y1 = (y1 - min(y1)) / (max(y1) - min(y1));
y2 = (y2 - min(y2)) / (max(y2) - min(y2));
fHand2 = figure;
aHand2 = axes('parent', fHand2);
hold(aHand2, 'on')
plot(x1, y1, 'parent', aHand2);
plot(x2, y2, 'parent', aHand2);
set(aHand2, 'YTickLabel', [])
Let me know if this solves your problem.
~Jonathan

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 10일
Consider using a waterfall plot.

카테고리

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