| [ Web Proxy ] |
| Viewing: https://matplotlib.org/gallery/mplot3d/../axes_grid1/../../plot_types/basic/fill_between.html | [Back] [Original] |
Note
Go to the end to download the full example code.
Fill the area between two horizontal curves.
See fill_between.
[fill between]import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery')
# make data
np.random.seed(1)
x = np.linspace(0, 8, 16)
y1 = 3 + 4*x/8 + np.random.uniform(0.0, 0.5, len(x))
y2 = 1 + 2*x/8 + np.random.uniform(0.0, 0.5, len(x))
# plot
fig, ax = plt.subplots()
ax.fill_between(x, y1, y2, alpha=.5, linewidth=0)
ax.plot(x, (y1 + y2)/2, linewidth=2)
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
ylim=(0, 8), yticks=np.arange(1, 8))
plt.show()
| Web Proxy Viewer | New URL | Original Page |