具有置信区间和引导程序的pandas中的Boxplot返回异常 - 使用iris数据集的可重现示例

时间:2018-04-27 12:17:16

标签: python pandas matplotlib boxplot

我试图用置信区间绘制一个箱线图,但我得到了一个例外。

<HashRouter>

Youradvice将不胜感激

1 个答案:

答案 0 :(得分:0)

您需要将置信区间指定为与您正在绘制的要素对应的元组列表。在您的情况下,您只绘制列'a',因此您需要指定一个包含一个元组的列表:

iris.boxplot(column='a', figsize=(15,20), notch=True, showmeans = True, \ 
             patch_artist = True, conf_intervals = [(4, 7)], bootstrap = 10000)

plt.show()

生成下图

enter image description here

但是,根据文档,如果您进行自举,则conf_intervals应为None,因为它会覆盖bootstrapping计算的参数。 https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.boxplot.html

因此,对于'a',如果conf_intervals为None,则输出为:

iris.boxplot(column='a', figsize=(15,20), notch=True, showmeans = True, \
             patch_artist = True, conf_intervals = [None], bootstrap = 10000)

plt.show()

enter image description here