为什么matplotlib的有缺口的boxplot会自动折叠?

2024-03-29 09:46:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用matplotlib制作一个有缺口的盒形图,但发现缺口盒往往会过度伸展,然后会自行折叠。当我做一个常规的箱线图时,不会发生这种情况。在

下面的代码和生成的结果图可以看出这一点:

import matplotlib.pyplot as plt

data = [[-0.056, -0.037, 0.010, 0.077, 0.082],
        [-0.014, 0.021, 0.051, 0.073, 0.079]]

# Set 2 plots with vertical layout (1 on top of other)
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)

ax1.boxplot(data, 1) #Notched boxplot
ax2.boxplot(data, 0) #Standard boxplot

ax1.set_ylim([-0.1, 0.1])
ax2.set_ylim([-0.1, 0.1])

plt.show()

Bad Notched Boxplot and Std. boxplot

有人知道我做错了什么吗?我该怎么解决这个问题?在


Tags: datamatplotlib情况plt常规set过度线图
1条回答
网友
1楼 · 发布于 2024-03-29 09:46:33

这意味着数据的分布是倾斜的。 如果两个盒子的切口不重叠,则有95%的置信度它们的中间值不同。在

缺口显示中值周围的置信区间,通常基于:enter image description here

enter image description here

也许,你可以改变boxplot^{}参数来收紧中位数的置信区间。在

相关问题 更多 >