How to plot multiple graphs with same x-axis?
29 ビュー (過去 30 日間)
古いコメントを表示
Abdul Rehan Khan Mohammed
2018 年 10 月 18 日
コメント済み: Mohamed Elnagdy
2021 年 9 月 16 日
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!