How to shade region under the curve in matplotlib

Solution 1:

The final answer I came up with is to use fill_between.

I thought there would have been a simple shade between type method, but this does exactly what I want.

section = np.arange(-1, 1, 1/20.)
plt.fill_between(section,f(section))

Solution 2:

Check out fill. Here's an example on filling a constrained region.