import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
填充
x = np.random.rand(10)
print(x)
x = x.cumsum()
print(x)
[0.16291293 0.78287339 0.84420882 0.78009326 0.12563782 0.34622635
0.29423626 0.97209634 0.11211394 0.58629993]
[0.16291293 0.94578631 1.78999513 2.57008839 2.69572621 3.04195255
3.33618881 4.30828515 4.42039909 5.00669902]
y = np.linspace(0,10,10)
fig, ax = plt.subplots()
ax.fill_between(x,y,color='lightblue')
<matplotlib.collections.PolyCollection at 0x2dcfad52e80>
x = np.linspace(0,10,200)
y1 = 2*x + 1
y2 = 3*x + 2
y_mean = 0.5*x*np.cos(2*x) + 2.5*x + 1.1
fig, ax = plt.subplots()
ax.fill_between(x,y1,y2,color='lightblue')
ax.plot(x,y_mean)
[<matplotlib.lines.Line2D at 0x2dcfb056e48>]