问题描述
我尝试使用matplotlib制作一个有缺口的箱形图,但发现有缺口的箱形往往会过度延伸,然后自身折回去.当我制作常规箱线图时不会发生这种情况.
I tried to make a notched boxplot using matplotlib, but found the notched box tends to overextend and then fold back on itself. This does not happen when I make a regular boxplot.
这可以通过以下代码以及生成的结果图看到:
This can be seen with the following code and the resulting plot that gets generated:
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()
有人知道我在做什么错吗,我该如何解决?
Does anyone know what I'm doing wrong and how I can fix this?
推荐答案
这意味着数据的分布是倾斜的.如果两个框的缺口不重叠,则它们的中位数不同的置信度为 95%.
It means that the distribution of the data is skewed.If two boxes' notches do not overlap, there is 95% confidence their medians differ.
Notch会在中位数附近显示置信区间,该置信区间通常基于:
The Notch displays the confidence interval around the median which is normally based on :
也许,您可以更改 bootstrap
a> boxplot
的参数以收紧中位数的置信区间.
这篇关于为什么matplotlib的带凹口的箱线图会自身折回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!