How to plot multiple graphs with same x-axis?

38 Ansichten (letzte 30 Tage)
Abdul Rehan Khan Mohammed
Abdul Rehan Khan Mohammed am 18 Okt. 2018
Kommentiert: Mohamed Elnagdy am 16 Sep. 2021
I have to draw 8 figures seperately but in a same graph for comparsion (same x-axis and differnt y-axis). I have used the code mentioned below. However, I am able to draw this for only 2 figures (figure attached). I want to do this same with 8 figures. Can anyone kindly, let me know what changes I have to make in the code so that it works for all the figures not just 2 figures.
if true
% figure(1)
x1=subplot(2,1,1);
stairs(DDr.Var1,DDr.Var2);
legend('Station 1 LHS')
ylabel('Cycle time')
title('Station 1 RHS & LHS hourly mean cycle time')
set(gca,'XTickLabel',[]);
ylim([0 105]);
x2=subplot(2,1,2);
stairs(DDr.Var1,DDr.Var3);
ylabel('Cycle time')
legend(' Station 1 RHS')
ylim([0 105]);
p1 = get(x1, 'Position');
p2 = get(x2, 'Position');
p1(2) = p2(2)+p2(4);
set(x1, 'pos', p1);
xlabel('Time')
end
  1 Kommentar
Mohamed Elnagdy
Mohamed Elnagdy am 16 Sep. 2021
it's because you have specified the number of graphs to be two in this line ''x1=subplot(2,1,1);
the first number is refered to as m in matlab's documentation, if you need 8, the replace the 2 with 8 and rearrange your plots as you wish

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 18 Okt. 2018
If you're using release R2018b or later, consider using stackedplot. There's an example on that page, "Change Individual Plots to Scatter and Stair Plots", showing how to change the plots into stairs plots.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by