python - mustache 被定义为 1.5* IQR,python seaborn boxplot 中的两个 mustache 怎么会不同呢?

标签 python matplotlib seaborn boxplot

根据seaborn documentation ,其箱线图方法使晶须的长度为 1.5*IQR。然而,从该文档的情节中可以看出,情况似乎并非如此。 上下须不一样。此外,它似乎不是 1.5 IQR。

有人可以解释一下他们为什么不同吗?

enter image description here https://seaborn.pydata.org/generated/seaborn.boxplot.html

最佳答案

原则上,如果箱线图上的须线使用四分位距 (IQR) 的倍数,则它们应该具有相等的长度,这一假设是正确的。

但是,本质上有两种情况并非如此。不幸的是,英文维基百科版本没有说明这些原因,但让我翻译一下german wikipedia中的解释。 :

Whisker
One possible definition, originating from John W. Tukey, is to restrict the length of the whisker to maximally 1.5 times the inter quartile range (1.5*IQR).

In this case the whisker does however not end exactly at this value, but rather at the value from the data which still lies inside of this boundary. The length of the whisker is hence determined by the data and not solemnly by the inter quartile range. This is the reason why the whisker does not need to be of the same size on both ends of the box. If there are no values outside of the 1.5*IQR boundary, the length of the whisker is determined by the minimal and maximal value. Otherwise, the values outside of the whiskers are marked separately in the diagram; those values can then be treated as outliers.

来自同一维基百科页面的绘图可能会使这一点更加明显:

enter image description here

对于问题中显示的图表,第二个原因肯定适用:即下须线在最低数据值的位置结束。

关于python - mustache 被定义为 1.5* IQR,python seaborn boxplot 中的两个 mustache 怎么会不同呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49139299/

相关文章:

python - 要添加到新列表 Python/Django 中的特定元素排序

python - 在 matplotlibrc Ubuntu 中导入 Open Sans 字体失败

python - 如何将 sns.facetgrid 保存为 pdf

python - matplotlib.figure.Figure.add_subplots() 和 add_axes() 返回 None 而不是轴

python - 带有 2 个 y 轴的 Seaborn 箱线图

python - seaborn和networkx可以通过matplotlib集成到GUI中吗?

python - python中嵌入式循环的多线程

python - 可空列的 Django REST ViewSet 排序

Python 路径在 Django 中不一致 - 双模块导入

matplotlib - matplotlib 中颜色条的几何形状