Matplotlib building error plots using the pandas framework

I am sure this is relatively easy, but I cannot get it to work. I would like to build this df with the date as the x axis, gas as the y axis and std as errors using the matplotlib module. I can make it work with the pandas shell, but then I have no idea how to style errors.

Using pandas matplotlib wrappers

I can build error diagrams using the matplotlib pandas shell trip.plot(yerr='std', ax=ax, marker ='D')But then I’m not sure how to access the error bars so that they can be styled as matplotlib could be used usingplt.errorbar()

Using Matplotlib

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

or

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

The above code is causing this error 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
+4
1

std - , ex df.std().

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

mpl1.5.0 +

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

Source: https://habr.com/ru/post/1629942/


All Articles