Search code examples
pythonmatplotlibfill

Matplotlib fill between horizontal threshold line and plot


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

Solution

  • 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')