Python 没有异常值的 Matplotlib 箱线图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22028064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Matplotlib boxplot without outliers
提问by Didac Busquets
Is there any way of hiding the outliers when plotting a boxplot in matplotlib (python)?
在 matplotlib (python) 中绘制箱线图时,有没有办法隐藏异常值?
I'm using the simplest way of plotting it:
我正在使用最简单的绘制方法:
from pylab import *
boxplot([1,2,3,4,5,10])
show()
This gives me the following plot:
这给了我以下情节:
(I cannot post the image because I have not enough reputation, but basically it is a boxplot with Q1 at y=1, Q3 at y=5, and the outlier at y=10)
(我无法发布图像,因为我没有足够的声誉,但基本上它是一个箱线图,Q1 在 y=1,Q3 在 y=5,离群值在 y=10)
I would like to remove the outlier at y=10, so that the plot only shows from Q1 to Q3 (in this case from 1 to 5).
我想删除 y=10 处的异常值,以便绘图只显示从 Q1 到 Q3(在这种情况下从 1 到 5)。
采纳答案by tom10
In current versions of matplotlib you can do:
在当前版本的 matplotlib 中,您可以执行以下操作:
boxplot([1,2,3,4,5,10], showfliers=False)
or
或者
boxplot([1,2,3,4,5,10], sym='')
In older versions, only the second approach will work.
在旧版本中,只有第二种方法有效。
The docsfor boxplotdo mention this, btw as, "Enter an empty string (‘') if you don't want to show fliers.", though, at least for myself, "outliers" is the more familiar word.
该文档为boxplot做“如果你不希望显示传单输入一个空字符串(‘’)。”提到这一点,顺便说一句的,不过,至少对我自己,“异常值”是比较熟悉的词。

