I made a chart with 2 line graphs. The red line is the high temperature of the day and the blue line is the low temperature of the day. Temps is the Dataframe, High is the high temp, Low is the low temp.
Temps = Temps.set_index('Date')
Temps['High'].plot()
Temps['Low'].plot()
Here's the resulting chart:
How do I automatically fill-in the area above the red line with solid red color? And then automatically fill-in the area below the blue line with solid blue color? Is it possible with MatPlotLib to make it something like the chart below (excuse the crude Paint job)?
Here is how I will approach it:
import numpy as np
import matplotlib.pyplot as plt
n = 20
low = 10 * np.random.rand(n, 1)
high = low + 5
f, ax = plt.subplots(1, 1)
ax.plot(range(n), low, color='g')
ax.plot(range(n), high, color='r')
ax.fill_between(range(n), low.squeeze(), ax.get_ylim()[0], color='g')
ax.fill_between(range(n), ax.get_ylim()[1], high.squeeze(), color='r')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With