I have plotted a graph with dataset df
, where Timestamp
is the index:
df
:
Timestamp Temperature
2020-02-06 08:23:04 18.5
2020-02-06 08:23:05 18.5
2020-02-06 08:23:06 18.5
2020-02-06 08:23:07 18.5
2020-02-06 08:23:08 18.5
... ... ...
2020-02-06 20:14:36 21.0
and code
df.plot( y='Temperature', figsize=(16, 10),)
plt.axhline(y=40, color='r', linestyle='-')
plt.axhline(y=25, color='b', linestyle='-')
plt.show()
The graph looks like this:
I would like to fill in colour for area where temperature is between 25°C and 40°C(inside the triangle). Can I do this by tweaking my code? If not, what's a good way of doing this? Thanks!
Note: The data is not continuous, but has been forward filled to have constant interval of 1 second. Also, temperature at the peak is above 40°C and the corresponding vertical section in Timestamp
should not be coloured.