am trying to plot some specific timeperiods of a timeserie with the dateformat DD.MM.YYYY HH:MM
already tried this:
data1 = pd.read_csv(InputPath1 ,sep=";", encoding="iso-8859-1", header=0, parse_dates=True, dayfirst=True, index_col="time")
y1=data1["Q"]
plt.plot(y1)
plt.xlim(pd.to_datetime('01.05.2019 00:00'), pd.to_datetime('01.06.2019 12:00'))
the dates will be plotted correctly without using xlim(). But when I set xlim() the day and month will be replaced (the x-axis shows 05.01.2019 instead of 01.05.2019). Any idea how to fix this?
thanks
CodePudding user response:
I found the solution:
plt.xlim(pd.to_datetime('10.07.2021 20:39',format="%d.%m.%Y %H:%M"), pd.to_datetime('12.07.2021 00:00',format="%d.%m.%Y %H:%M"))