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 Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by