Plotting multiple boxplots within the same plot/figure
23 views (last 30 days)
Show older comments
I have six variables that I would like to plot within the same figure/plot as individual box-plots. I have tried doing so by plotting one, then using 'hold on' before the plotting the next, but this hasn't worked. How might I go about doing this?
Thank you.
2 Comments
Accepted Answer
Walter Roberson
on 1 Dec 2012
subplot(3,1,1)
boxplot(mat1, 'notch', 'on', 'colors', 'r')
subplot(3,1,2)
boxplot(mat2, 'notch', 'on', 'colors', 'b')
subplot(3,1,3)
boxplot(mat3, 'notch', 'on', 'colors', 'c')
More Answers (1)
Emma
on 1 Dec 2012
1 Comment
Walter Roberson
on 1 Dec 2012
shortcut:
NMat = nan(6, 10000);
And since you are copying the same number of columns for each you can eliminate the other lines:
boxplot( [mat1(:), mat2(:), mat3(:), mat4(:), mat5(:), mat6(:)], 'notch', 'on', 'color', 'rb')
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!