How to plot multiple graphs with same x-axis?

33 visualizaciones (últimos 30 días)
Abdul Rehan Khan Mohammed
Abdul Rehan Khan Mohammed el 18 de Oct. de 2018
Comentada: Mohamed Elnagdy el 16 de Sept. de 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 comentario
Mohamed Elnagdy
Mohamed Elnagdy el 16 de Sept. de 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

Iniciar sesión para comentar.

Respuesta aceptada

Steven Lord
Steven Lord el 18 de Oct. de 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.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by