How to plot multiple graphs with same x-axis?
38 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mohamed Elnagdy
2021-9-16
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
采纳的回答
Steven Lord
2018-10-18
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!