晶须长度不同的Python箱形图 [英] Python boxplots having different whisker lengths
问题描述
我在 Pandas 中使用了 DataFrame.boxplot()
函数,我相信它调用了 matplotlib.pyplot.boxplot()
.文档说这些箱形图的默认晶须长度应为1.5IQR,但我不明白为什么同一盒中的上/下晶须长度不同.(我没有做任何特定的配置)
I was using the DataFrame.boxplot()
function in Pandas, which I believe calls the matplotlib.pyplot.boxplot()
. The documentation says that the default whisker length of these boxplots should be 1.5IQR, but I don't understand why the upper/lower whiskers of the same box are of different lengths in the plot. (I have not done any specific configurations)
对不起,我想发布图片,但我没有足够的声誉,所以我把它放在一个免费的图片托管网站上,链接:
Sorry I wanted to post the image but I do not have enough reputation, so I put it on a free image hosting site instead, link:
http://postimg.org/image/z0xtfg9gd/
推荐答案
听起来像是对箱线图的普遍误解.
Sounds like a general misunderstanding of boxplots.
从一个箱线图到任何其他箱线图的胡须长度不同的原因有两个
There are two reasons whiskers length vary from one boxplot to any other boxplot
- 每个数据集的 IQR 都不同
- 晶须仅延伸Q1-1.5 IQR和Q3 + 1.5 IQR范围内的最外点.因此,如果Q3 + 1.5 * IQR = 75,但是样本的最大值为70,则晶须绘制为70.
- The IQRs for each of the datasets are different
- The whiskers extend only the outermost points within that Q1 - 1.5IQR and Q3 + 1.5IQR range. So if Q3 + 1.5*IQR = 75, but the max value of your sample is 70, the whisker is drawn at 70.
这个答案给出了箱线图的完整解释构造而成,包括图纸.
This answer gives a full explanation how boxplots are constructed including a drawing.
这篇关于晶须长度不同的Python箱形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!