I want to use matplotlib to illustrate the definite integral between two regions: x_0, and x_1.

How can I shade a region under a curve in matplotlib from x=-1, to x=1 given the following plot

```
import numpy as np
from matplotlib import pyplot as plt
def f(t):
return t * t
t = np.arange(-4,4,1/40.)
plt.plot(t,f(t))
```

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))
```

Licensed under: CC-BY-SA with attribution

Not affiliated with: Stack Overflow