I'm trying to create a shaded rectangle based on two vertical coordinates (the length of the rectangle should span the whole x axis).
I've tried to use fill_between
with the following (p1 & p2 are the data coordinates):
f, ax1 = plt.subplots()
x = np.linspace(200,300,2000)
y = x**(2)
y1 = x
p1 = 4700
p2 = 7700
ax1.plot(x, y, lw=2)
ax1.set_xlabel('Temperature $[K]$', fontweight='bold')
ax1.set_ylabel('Pressure $[mb]$', fontweight='bold')
ax1.fill_between(x, y1.fill(p1), y1.fill(p2))
But i'm getting the following error:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
What is wrong? Any better way to do this?
Thank you!!