- observation within the whisker length (the adjacent value).
- Observations beyond the whisker length are marked as outliers. By default, an outlier is a value that is more than 1.5 times the interquartile range away from the bottom or top of the box. However, you can adjust this value by using additional input arguments. An outlier appears as a red + sign. (emphasis added --dpb)
Why doesn't the standard deviation show on boxplot?
9 views (last 30 days)
Show older comments
Hi, I'm having an issue with my code. As you can see, the total and catagory 1 is plotted appropriately. The catagory 2 plot has a red x and no upper standard deviation plotted and I can't figure out why. Thank you!
close all
clear
T = readtable("BFR_ToPlot.xlsx");
A = T.Active(1:5);
B = T.OsteoisOcy(1:5);
C = T.Alone(1:5);
group =[ones(size(A));2*ones(size(B));3*ones(size(C))];
figure
hold on
boxplot([A;B;C],group,'color','k')
scatter(group, [A;B;C],'k')
somenames={'Total'; '1'; '2' };
0 Comments
Accepted Answer
dpb
on 27 Sep 2023
Edited: dpb
on 5 Oct 2023
Per the usual caveat, to be able to dig deeper would take having the actual data, at least for that case...although knowing there were 5 points can create a sample dataset that duplicates the appearance
v=[25 38 40 40 65];
subplot(1,3,2)
boxplot(v,'color','k')
hold on
scatter(1,v)
ylim([0 305])
q=quantile(v,[0.25 0.75])
v(v>q(2)&v<max(v))
shows that there are no points less than the max that are greater than the upper (75th) quantile and by definition of an outlier as above/below 1.5x the quantile range
upperoutlimit=q(2)+1.5*diff(q)
outlier=(v(end)>=upperoutlimit)
shows the last point is, indeed, an outlier by that definition and since there's no other value sabove the upper quantile as max that is not an outlier, there is no upper whisker to show that value.
loweroutlimit=q(1)-1.5*diff(q)
outlier=(v(1)<=loweroutlimit)
You'll be able to verify the same tests with the exact values you have/used.
The particular dataset is anomalous owing to the one outlier and in having so few elements that that one outlier creates the situation you see.
As far as the standard deviation, the box plot doesn't show it at all at any time.
2 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!