physiker
physiker

Reputation: 919

matplotlib fill between discrete points

I have the following few data points (no equation to address y1 and y2).

Q: How can I fill the area between the points with a different color? Thanks!

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()

enter image description here

Upvotes: 1

Views: 6185

Answers (1)

CT Zhu
CT Zhu

Reputation: 54370

Please just do:

plt.fill_betweenx(X, Y, 35) #or max(X) or whatever cut-off you may want.

enter image description here

Upvotes: 2

Related Questions