【发布时间】:2017-03-21 06:31:39
【问题描述】:
因此,我计算了一组具有正态分布的数据的置信区间,我想将其绘制为数据均值条形图上的须线。我尝试对 plt.bar 使用 yerr 参数,但它计算的是标准偏差误差而不是置信区间。我想要条形图上相同的晶须可视化。 我的置信区间是:
[(29600.87 , 39367.28 ), (37101.74, 42849.60), (33661.12, 41470.25), (46019.20, 49577.80)]
这是我的代码,我尝试为 yerr 参数提供置信水平,但效果不佳。
means=[np.mean(df.iloc[x]) for x in range(len(df.index))]
CI=[st.t.interval(0.95, len(df.iloc[x])-1, loc=np.mean(df.iloc[x]), scale=st.sem(df.iloc[x])) for x in range(len(df.index))]
plt.figure()
plt.bar(x_axis, means, color='r',yerr=np.reshape(CI,(2,4))
plt.xticks(np.arange(1992,1996,1))
这是我得到的情节:
【问题讨论】:
标签: python matplotlib scipy