答案 0 :(得分:1)
可以使用fill_between
或import matplotlib.pyplot as plt
import numpy as np
#Define min and max line
minline = -10
maxline = 10
#Generate dummy plotting data
x = np.arange(0.0, 2, 0.01)
y1 = 25*np.sin(2*np.pi*x)-10
y2 = 30*np.sin(4*np.pi*x)-10
maxy=max(y1.max(),y2.max())
miny=min(y1.min(),y2.min())
fig, axs = plt.subplots(2,1)
#Plot dummy data
for ax in axs:
ax.plot(x,y1,'b')
ax.plot(x,y2,'g')
#Draw lines
axs[0].axhline(y=minline,color='r')
axs[0].axhline(y=maxline,color='r')
#Draw filled regions
axs[1].fill_between(x,minline,miny,color='r',alpha=0.3)
axs[1].fill_between(x,maxline,maxy,color='r',alpha=0.3)
plt.show()
函数
table{
width: 2200px;
}
给出,