Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36c0efa

Browse files
authored
Merge pull request #21237 from timhoffm/plot-types-fillbetween
DOC: Add fill_between to plot_types
2 parents 9d4560d + 1d77dcb commit 36c0efa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

plot_types/basic/fill_between.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
=======================
3+
fill_between(x, y1, y2)
4+
=======================
5+
6+
See `~matplotlib.axes.Axes.fill_between`.
7+
"""
8+
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
12+
plt.style.use('_mpl-gallery')
13+
14+
# make data
15+
np.random.seed(1)
16+
x = np.linspace(0, 8, 16)
17+
y1 = 3 + 4*x/8 + np.random.uniform(0.0, 0.5, len(x))
18+
y2 = 1 + 2*x/8 + np.random.uniform(0.0, 0.5, len(x))
19+
20+
# plot
21+
fig, ax = plt.subplots()
22+
23+
ax.fill_between(x, y1, y2, alpha=.5, linewidth=0)
24+
ax.plot(x, (y1 + y2)/2, linewidth=2)
25+
26+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
27+
ylim=(0, 8), yticks=np.arange(1, 8))
28+
29+
plt.show()

0 commit comments

Comments
 (0)