如何使用 Python 和 Plotly 创建不显示异常值的箱线图?
How to create a boxplot not showing the outliers using Python and Plotly?
如何使用 Python 和 Plotly 创建不显示异常值的箱线图?
我有一个完整的点列表,我用它来创建一个包含许多离群值的箱线图,并且范围对于可比较的箱线图来说太大了。
我根本不想在箱形图上显示此列表中的异常值。
- 有没有办法不在箱线图中显示异常值?
如果不是,那么我尝试在绘制数据之前从数据中删除异常值。然而,Plotly 提出了一些我没有删除的点作为异常值。
- 有没有办法创建一个箱线图,其中 none 个元素被视为异常值?
来自 Plotly 的安德鲁。
您不能只不显示数组中的某些数据。所以你可以设置 boxpoints: "all"
来获得点的抖动,包括异常值。这将使箱线图保持原样,上面没有异常值。我猜这不是你真正想要的。
为了防止在数据数组中发现异常值,设置boxpoints: false
所以在 Python 中,像这样的东西应该可以工作:
import plotly.plotly as py
from plotly.graph_objs import Box, Figure
fig = Figure()
boxpoints_default = Box(y=[1, 2, 3, 2, 1, 10], name='default')
boxpoints_false = Box(y=[1, 2, 3, 2, 1, 10], boxpoints=False, name='no outliers')
boxpoints_all = Box(y=[1, 2, 3, 2, 1, 10], boxpoints='all', name='jitter boxpoints')
fig['data'].extend([boxpoints_default, boxpoints_false, boxpoints_all])
fig['layout'].update(title='Comparing boxplot "boxpoints" settings')
py.iplot(fig, filename='Stack Overflow 31497537')
这是结果图:
https://plot.ly/~theengineear/4936/comparing-boxplot-boxpoints-settings/
这是一个 link 使用 Plotly 绘制箱线图的一般教程:
迟到了,但我找到了一个(也许是新的)简单的解决方案:
fig.update_traces(boxpoints=False)
如下所示:https://plotly.com/python/reference/box/
请注意,我不得不删除 selector=dict(type='box)
部分,因为它造成了错误。
如何使用 Python 和 Plotly 创建不显示异常值的箱线图?
我有一个完整的点列表,我用它来创建一个包含许多离群值的箱线图,并且范围对于可比较的箱线图来说太大了。
我根本不想在箱形图上显示此列表中的异常值。
- 有没有办法不在箱线图中显示异常值?
如果不是,那么我尝试在绘制数据之前从数据中删除异常值。然而,Plotly 提出了一些我没有删除的点作为异常值。
- 有没有办法创建一个箱线图,其中 none 个元素被视为异常值?
来自 Plotly 的安德鲁。
您不能只不显示数组中的某些数据。所以你可以设置
boxpoints: "all"
来获得点的抖动,包括异常值。这将使箱线图保持原样,上面没有异常值。我猜这不是你真正想要的。为了防止在数据数组中发现异常值,设置
boxpoints: false
所以在 Python 中,像这样的东西应该可以工作:
import plotly.plotly as py
from plotly.graph_objs import Box, Figure
fig = Figure()
boxpoints_default = Box(y=[1, 2, 3, 2, 1, 10], name='default')
boxpoints_false = Box(y=[1, 2, 3, 2, 1, 10], boxpoints=False, name='no outliers')
boxpoints_all = Box(y=[1, 2, 3, 2, 1, 10], boxpoints='all', name='jitter boxpoints')
fig['data'].extend([boxpoints_default, boxpoints_false, boxpoints_all])
fig['layout'].update(title='Comparing boxplot "boxpoints" settings')
py.iplot(fig, filename='Stack Overflow 31497537')
这是结果图:
https://plot.ly/~theengineear/4936/comparing-boxplot-boxpoints-settings/
这是一个 link 使用 Plotly 绘制箱线图的一般教程:
迟到了,但我找到了一个(也许是新的)简单的解决方案:
fig.update_traces(boxpoints=False)
如下所示:https://plotly.com/python/reference/box/
请注意,我不得不删除 selector=dict(type='box)
部分,因为它造成了错误。