How to change Y-axis in subplots of Boxplot on the same figure
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Jakob B. Nielsen
el 4 de Mzo. de 2020
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.
1 comentario
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!