Home > Back-end >  Fill area between nonlinear and diagonal lines
Fill area between nonlinear and diagonal lines

Time:10-06

Could you please help me with this issue. I was wondering how to fill the area between a nonlinear and diagonal lines. For example, in the following plot how we can fill the area above diagonal line red and the area below blue. In advance, I appritiate your time and consideration.

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize = (6,4))
x=np.array([0,1,2,3,4,5,6,7,8,9,10])
y=np.array([0,2,3,3,2,2,6,8,9,9,8])

ax.plot(x,y, color = "red", lw=1.2)
ax.plot([x.min(),x.max()],[y.min(),y.max()], color = "black", lw=1.2)

plt.show()

CodePudding user response:

The enter image description here

  • Related