axel briffault
axel briffault

Reputation: 11

Axes messed up trying to plot temporal series with matplotlib

I've got an issue when trying to plot two temporal series with Matplotlib. The temporal series should share the same y-axis/scale since it's supposed to be a comparison on modeled and measured values. However, when plotting, it seems that the y and x scales are getting messed up:

Graph of one month of my data

Here is the code associated:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import datetime as dt

#import des données
Data=pd.read_csv('Filepath/Recept_41R001.csv', sep=';')
Data['Date']=pd.to_datetime(Data['Date'])
Data.sort_values(by='Date')
Data.set_index('Date', inplace=True)

Data01=Data['2018-01-01 00:00:00':'2018-01-31 23:00:00']

fig, ax=plt.subplots()
ax.plot(recept0101.index, recept0101['NO2_Mod'])
ax.plot(recept0101.index, recept0101['NO2_Mes'])
ax.set_xlabel('Time')
ax.set_ylabel('NO2 µg/m3')
ax.set_title('NO2 Modeled vs Mesured 01-2018')
ax.legend(['Modeled NO2','Mesured NO2'])
plt.show()

Upvotes: 1

Views: 128

Answers (1)

Werner Barros
Werner Barros

Reputation: 11

Try to put

ax.plot(recept0101.index, recept0101['NO2_Mod'], linestyle='--')

ax.plot(recept0101.index, recept0101['NO2_Mes']),linestyle='--')

Upvotes: 1

Related Questions