如何防止在 pandas 中的箱线图中绘制异常值
How to prevent from plotting outlier in boxplot in pandas
我有一个 DataFrame(称为 result_df
),想用箱线图绘制一列。
但是某些异常值破坏了可视化效果。我怎样才能防止绘制异常值?
我使用的代码:
fig, ax = pl.subplots()
fig.set_size_inches(18.5,10.5)
result_df.boxplot(ax=ax)
pl.show()
重要提示:我没有给予足够的重视,显然这种情况经常发生,我错过了它是 pandas
具体的。但是,从我看到的问题来看,它基本上是用于在后台绘图的 matplotlib,因此它仍然可以工作。抱歉我没注意。
幸运的是你有这样的事情。在页面底部 results: dict
标题下的 manual 中,它指出:
fliers: points representing data that extend beyond the whiskers
(outliers).
设置showfliers=False
希望对您有所帮助。
不过我不得不提的是,我发现他们将离群值缩短为传单真的很奇怪。如果这没有帮助 manual 提供第二个解决方案:
sym : str or None, default = None
The default symbol for flier points. Enter an empty string (‘’) if you don’t want to show fliers. If None, then the fliers default to
‘b+’ If you want more control use the flierprops kwarg.
我有一个 DataFrame(称为 result_df
),想用箱线图绘制一列。
但是某些异常值破坏了可视化效果。我怎样才能防止绘制异常值?
我使用的代码:
fig, ax = pl.subplots()
fig.set_size_inches(18.5,10.5)
result_df.boxplot(ax=ax)
pl.show()
重要提示:我没有给予足够的重视,显然这种情况经常发生,我错过了它是 pandas
具体的。但是,从我看到的问题来看,它基本上是用于在后台绘图的 matplotlib,因此它仍然可以工作。抱歉我没注意。
幸运的是你有这样的事情。在页面底部 results: dict
标题下的 manual 中,它指出:
fliers: points representing data that extend beyond the whiskers (outliers).
设置showfliers=False
希望对您有所帮助。
不过我不得不提的是,我发现他们将离群值缩短为传单真的很奇怪。如果这没有帮助 manual 提供第二个解决方案:
sym : str or None, default = None
The default symbol for flier points. Enter an empty string (‘’) if you don’t want to show fliers. If None, then the fliers default to ‘b+’ If you want more control use the flierprops kwarg.