How to change the appearance of the boxplot with a whiskers?
106 views (last 30 days)
Show older comments
Hello everyone. I have the following code:
A = [1.128 0.701 0.562 0.469 0.836 0.644 0.510 0.535 0.528 0.585]';
B = [0.630 0.630 1.079 0.635 0.983 0.875 0.747 0.811 0.878 0.943]';
group = [ ones(size(A)); 2 * ones(size(B))];
figure
boxplot([A; B],group)
set(gca,'XTickLabel',{'group A','group B'})
I want to change the appearance of the two boxplots as shown in the figure on the right:
- change dashed line to continuous line
- change the sign of outliers form "+" with a dot or "o"
How is it possible to fix the code?
0 Comments
Accepted Answer
Matt J
on 20 Mar 2022
A = [1.128 0.701 0.562 0.469 0.836 0.644 0.510 0.535 0.528 0.585]';
B = [0.630 0.630 1.079 0.635 0.983 0.875 0.747 0.811 0.878 0.943]';
group = [ ones(size(A)); 2 * ones(size(B))];
figure
boxplot([A; B],group)
set(gca,'XTickLabel',{'group A','group B'})
h=findobj('LineStyle','--'); set(h, 'LineStyle','-');
h=findobj('Marker','+'); set(h, 'Marker','o'); set(h,'MarkerFaceColor','r')
2 Comments
Matt J
on 20 Mar 2022
For that you should probably check some of the other box plotting routines on the File Exchange. This is just one example which seems to offer that kind of control:
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!