How to put stacked plots in the same graph

J
johnwilson92 · Aug 31, 2020 · 2K views
Question
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.
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 24, 2026

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', [])
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!