Python 使用熊猫数据框打印错误栏matplotlib

Python 使用熊猫数据框打印错误栏matplotlib,python,pandas,matplotlib,plot,Python,Pandas,Matplotlib,Plot,我相信这是相对容易的,但我似乎无法使它工作。我想使用matplotlib模块绘制此df,日期为x轴,气体为y轴,标准为误差条。我可以让它工作使用熊猫包装,但我不知道如何风格的错误栏 使用matplotlib包装器 我可以使用matplotlib包装器trip.plot(yerr='std',ax=ax,marker='D')绘制错误条,但我不确定如何访问错误条,以便像使用plt.errorbar()在matplotlib中一样设置错误条的样式 使用Matplotlib fig, ax = plt

我相信这是相对容易的,但我似乎无法使它工作。我想使用matplotlib模块绘制此df,日期为x轴,气体为y轴,标准为误差条。我可以让它工作使用熊猫包装,但我不知道如何风格的错误栏

使用matplotlib包装器

我可以使用matplotlib包装器
trip.plot(yerr='std',ax=ax,marker='D')
绘制错误条,但我不确定如何访问错误条,以便像使用
plt.errorbar()在matplotlib中一样设置错误条的样式

使用Matplotlib

fig, ax = plt.subplots()
ax.bar(trip.index, trip.gas, yerr=trip.std)

上述代码引发此错误
TypeError:-:“float”和“instancemethod”的操作数类型不受支持

所以基本上,我想要的帮助是使用标准matplotlib模块而不是pandas包装器绘制错误条

DF==


std
是数据帧上的一种方法,例如
df.std()

使用

或者如果您有mpl1.5.0+

plt.errorbar(trip.index, 'gas', yerr='std', data=trip)

我知道这是一个非常古老的线程,但是使用df.std()作为估计器并不是一个好主意。它们通常不一样。相反,plz使用df.sem()。通常人们想要的是平均值的标准误差,而不是标准差。这可能是错误处理中最常见的错误,在许多出版物中也是错误的。至少有一种错误估计过高。;-)
        date       gas       std
0 2015-11-02  6.805351  7.447903
1 2015-11-03  4.751319  1.847106
2 2015-11-04  2.835403  0.927300
3 2015-11-05  7.291005  2.250171
plt.errorbar(trip.index, trip['gas'], yerr=trip['std'])
plt.errorbar(trip.index, 'gas', yerr='std', data=trip)