Home > Software engineering >  Matplotlib fill between horizontal threshold line and plot
Matplotlib fill between horizontal threshold line and plot

Time:07-02

How can I fill between my plot and a horizontal line that's not zero?

I've used the fill_betwee() method and it detects the correct points but it fills all the way from the x axis to my plot

enter image description here

Here's the code that I've done so far:

plt.fill_between(df.index, df['Data'], where= (df['Data'] > 205), color='orange')

CodePudding user response:

Fill between matplotlib, y0:start value, y1:end value,Where:range limited.

plt.fill_between(df.index, 205, df.Data, where=(df.Data > 205), color='orange')

CodePudding user response:

not sure but..

add a list with the same length as df["data"] with 205 for every entry.

plt.fill_between(df.index, df['Data'], [205, 205, ...], where= (df['Data'] > 205), color='orange')
  • Related