Search code examples
pythonpandasmatplotlibtemperature

Shading the area of Tmax and Tmin


I have generated a df of 366 days as an index and two columns, TMAX and TMIN, when graphing I get something coherent but by shading both lines the result does not make sense, any advice please?

dfM=df.TMAX.groupby('Day').max()
dfm=df.TMIM.groupby('Day').min()

plt.plot(dfM)
plt.plot(dfm)
plt.fill_between(x=dfM, y1=dfm, color='red', alpha=0.8)
plt.show()

enter image description here


Solution

  • Try to pass the correct x-values

    plt.fill_between(x=range(len(dfM)), y1=dfM, y2=dfm, color='red', alpha=0.8)