Matplotlib - Changing line color above/below hline

Viewed 3016

I have a line plot and 2 hlines, all using different colors, and I'm filling the areas where the main line crosses the hlines with the color of the hline. In addition to that, I'd like to use the same color for the main line in those areas. In a nutshell, current output: enter image description here

Desired output: enter image description here

And the relevant code I'm currently using:

lower, upper = 20, 80

self.indicatorPlot.axhline(lower, color="red")
self.indicatorPlot.axhline(upper, color="green")

self.indicatorPlot.plot(self.chartTimes, self.indicatorData, color="blue")

self.indicatorPlot.fill_between(self.chartTimes, self.indicatorData, lower, where=(self.indicatorData <= lower), facecolor="red", interpolate=True)
self.indicatorPlot.fill_between(self.chartTimes, self.indicatorData, upper, where=(self.indicatorData >= upper), facecolor="green", interpolate=True)
1 Answers
Related