hse*_*bie 7 python plot matplotlib pandas
我相信这相对容易,但我似乎无法使其发挥作用.我想绘制这个df,使用matplotlib模块将日期作为x轴,将气体作为y轴,将std作为错误栏.我可以使用pandas包装器来使用它,但后来我不知道如何设置错误栏的样式.
使用pandas matplotlib包装器
我可以使用matplotlib pandas包装器绘制错误栏trip.plot(yerr='std', ax=ax, marker ='D')然后我不知道如何访问错误栏来设置它们就像在matplotlib中使用它一样plt.errorbar()
使用Matplotlib
fig, ax = plt.subplots()
ax.bar(trip.index, trip.gas, yerr=trip.std)
要么
plt.errorbar(trip.index, trip.gas, yerr=trip.std)
上面的代码抛出了这个错误 TypeError: unsupported operand type(s) for -: 'float' and 'instancemethod'
基本上,我想要帮助的是使用标准matplotlib模块而不是pandas包装器绘制错误栏.
DF ==
        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
tac*_*ell 12
std是一种数据帧的方法,例如df.std().
使用
plt.errorbar(trip.index, trip['gas'], yerr=trip['std'])
或者如果你有mpl1.5.0 +
plt.errorbar(trip.index, 'gas', yerr='std', data=trip)
| 归档时间: | 
 | 
| 查看次数: | 8949 次 | 
| 最近记录: |