I'm plotting a variable which changes over time, and I want to indicate the severity of the variable in a traffic light style.
|
|
| red
|
|
y| /
| / yellow
| ___ /
| / \_/
| / green
| /
|_____________________________
x
So for low y values, the background is green, for intermediate it's yellow/amber, and for high values it's red. It would end up looking a bit like a three-striped flag.
It's made more complicated by the fact that I'm replotting this frequently and the y scale may change, so I can't just put fixed boxes on the plot, unless maybe I calculate the box size every time I plot.
Is there a way to do this with matplotlib?
My plotting code at the moment:
import matplotlib.pyplot as plt
plt.plot(x, y, 'k')
plt.grid(b=True)
ax = plt.gca()
ax.set_facecolor("some colour")