Filling range of graph in matplotlib

Viewed 2556

I have a line graph that I'm making using matplotlib. I'm trying to add a fill behind the line such that the filled area is from current_val - standard_deviation to current_val + standard deviation. So far I've read the documentation and I was originally getting a fill line only at the y-intercept of the first coordinate.

My code is currently as follows:

data_field = 'Mean'
row_index = 'Rvolt'
x_axis = buckets
y_axis = df_result.loc[df_result.index.isin([row_index]) & df_result['Bucket'].between(1, 144), data_field].tolist()
plt.plot(x_axis, y_axis)
plt.xlabel("Bucket Spans")
plt.ylabel(data_field + " values for " + row_index)
#plt.fill(x_axis, y_axis)
plt.show()

How do I get it such that my graph eventually looks a little bit like this

For further disclosure, my x & y axes are lists.

2 Answers
Related