How to add standard deviation to the boxplot?

Having boxplot, I added mean value by hold on command on the box plot. I wanted to know whether it is common to add standard deviation to the boxplot? Becase boxplot is based on median and quartile I am not sure if it is bizarre to add std to the plot or not. and how to do it?

댓글 수: 1

How did you get this plot? I'm trying boxplot to plot the error on my data but unable to do it. Can you show me your code? or just type the boxplotting code?

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam Danz
Adam Danz 2020년 1월 2일
편집: Adam Danz 2020년 1월 2일

0 개 추천

I wouldn't call it bizarre. Often times it's useful to compare means/medians and IQR/std. It may reveal how skewed your data are. Instead of plotting the means using plot(), you can plot the means and standard deviation using errorbar(x,y,neg,pos,'s') where x are the boxplot centers, y are the means, neg/pos are the -/+ std, and 's' will show a square marker for the mean values.
Or maybe you want to show 2 standard deviations using
errorbar(x, y, -2*std(...), 2*(std...), 's')

댓글 수: 5

I used errorbar(x,y,err) in which x is the center of boxplot in x-axis and y is the mean value. But the output is this:
1.JPG
the green diamond is the mean value.
The value for std (33.73) and mean (3987) are:
2.JPG
apparently the std is add to the min and max of the boxplot not the mean value.
How can I solve the issue?
"apparently the std is add to the min and max of the boxplot not the mean value."
What does that mean? Your call to errorbar() is completely independent from the boxplot so how could it affect the boxplot? It looks to me like your errorbars are correct. They span +/- 33.73 from the mean.
The plot shows that your median approximately equals the mean and the IQR is a little less than 2 stds. Is this unexpected?
The only thing I'd change is to plot the mean value using errorbar,
errorbar(x,y,err, 'go'
The mean is 3987 and STD is 33.73. 3987+33.73 and 3987-33.73 are the numbers I am expecting but if you see the plot, theyupper bond of std is more than 4010 and lower bound is less than 3960. Does this make sense?
Adam Danz
Adam Danz 2020년 1월 5일
편집: Adam Danz 2020년 1월 6일
Yes, it makes perfect sense.
3987 + [-33.73, 33.73]
ans =
3953.3 4020.7
Those are the upper and lower bounds of your error bars if you're plotting +/- 1 std. Were you expecting something different?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Errorbars에 대해 자세히 알아보기

질문:

2020년 1월 2일

댓글:

2021년 4월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by