I'm trying to plot a graph of time x precipitation, however, the values on the x-axis don't match the values on the y-axis. The plot itself it's correct, but the x-axis is not. The context is that I created a Prophet model to predict monthly precipitation, after generating the values, I plotted the test against the prediction, and while the lines seem correct, the dates look shifted one 'unit' to the left:
Precipitation x Month:
Test Values:
Date Precipitation
443 2020-12-31 273.2
444 2021-01-31 215.5
445 2021-02-28 180.6
446 2021-03-31 138.4
447 2021-04-30 54.4
448 2021-05-31 44.4
449 2021-06-30 16.2
450 2021-07-31 39.4
451 2021-08-31 44.4
452 2021-09-30 39.5
453 2021-10-31 91.9
454 2021-11-30 98.6
455 2021-12-31 127.3
456 2022-01-31 308.5
Prediction Values:
Date Precipitation
443 2020-12-31 133.7
444 2021-01-31 272.0
445 2021-02-28 222.0
446 2021-03-31 177.3
447 2021-04-30 75.9
448 2021-05-31 81.5
449 2021-06-30 31.9
450 2021-07-31 41.7
451 2021-08-31 28.9
452 2021-09-30 42.9
453 2021-10-31 111.4
454 2021-11-30 129.5
455 2021-12-31 126.2
456 2022-01-31 299.1
We can observe that the first value should be for 2020-12 but that's not the case.
fig = plt.figure(figsize=(12, 8))
plt.plot(test.Date, test.Precipitation, 's-r')
plt.plot(previsao.Date, previsao.Precipitation, 's-b')
plt.title('Precipitação por Mês na Cidade de São Paulo em $mm$', fontsize=20)
plt.ylabel('Precipitação ($mm$)', fontsize=12)
plt.xlabel('Ano')
plt.legend(['Real', 'Previsão']);
plt.show()
Can anyone point out what I'm doing wrong here? I believe I'm doing something wrong when plotting the graph but I cannot figure it out.