我有以下几个数据点(没有方程式来解决y1和y2)。
问:我如何用不同的颜色填充点之间的区域?谢谢!import matplotlib.pyplot as plt
from matplotlib.figure import Figure
X=[-10,-15,-20,-25,-100,-200,-300,-400,-500,-600]
Y=[35,20,10,8,6,12,15,20,25,30]
fig = plt.figure()
ax= fig.add_subplot ( 111 )
ax.plot(Y,X,'ro-')
ax.text(20, -200, 'HOW TO FILL HERE?', fontsize=30)
plt.show()
答案 0 :(得分:2)
请做:
plt.fill_betweenx(X, Y, 35) #or max(X) or whatever cut-off you may want.