How to change Y-axis in subplots of Boxplot on the same figure
27 ビュー (過去 30 日間)
古いコメントを表示
I need help with creating 4 boxplots in one figure where in each subplot I would like to assign the ylim. In this example, the ylim looks nice and no need to change it but in my model I want to change it. Thanks for your help in advance.
% this is just an example and in my code the values vary more. Thus, need to change the ylim in each plot.
r1 = 10*rand(5);
r2 = 100*rand(6);
r3 = 1000*rand(7);
r4 = 10000*rand(8);
r = {r1, r2, r3, r4};
for i = 1:4
subplot1 = subplot(4,1,i);
boxplot(r{i}); hold on
ylim()
end
0 件のコメント
回答 (1 件)
Jakob B. Nielsen
2020 年 3 月 4 日
You need a reference back to each inidividual subplot. Right now, your subplot1 label is overwritten each time, so you can only refer back to your 4th and final plot. Index it, so you get a reference to all four subplot axes.
r1 = 10*rand(5);
r2 = 100*rand(6);
r3 = 1000*rand(7);
r4 = 10000*rand(8);
r = {r1, r2, r3, r4};
for i = 1:4
subplot1(i) = subplot(4,1,i); %this turns subplot1 into a 1x4 axes
boxplot(r{i}); hold on
end
ylim(subplot(1),[0 100]) %just for example.
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!