How to put stacked plots in the same graph
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!