Python直方图错误条

Python直方图错误条,python,matplotlib,Python,Matplotlib,我尝试使用以下方法将错误条添加到直方图中: 数据=np.随机.正态10,1100 plt.histdata,料仓=np.arange0,20,0.5,规范=1 plt.errorbarargument,参数,yerr=0.01 为了在每个箱子的顶部绘制错误条,我应该使用哪些参数?我更喜欢使用这种绘图方法…谢谢 您需要使用以下结果: 直线mid=0.5*bins[1:]+bins[:-1]只计算条形图的中点 data = np.random.normal(10,1,100) n, bins, _

我尝试使用以下方法将错误条添加到直方图中: 数据=np.随机.正态10,1100 plt.histdata,料仓=np.arange0,20,0.5,规范=1 plt.errorbarargument,参数,yerr=0.01


为了在每个箱子的顶部绘制错误条,我应该使用哪些参数?我更喜欢使用这种绘图方法…谢谢

您需要使用以下结果:

直线mid=0.5*bins[1:]+bins[:-1]只计算条形图的中点

data = np.random.normal(10,1,100)
n, bins, _ = plt.hist(data, bins=np.arange(0,20,0.5),normed=1)
mid = 0.5*(bins[1:] + bins[:-1])
plt.errorbar(mid, n, yerr=0.01, fmt='none')