I'm trying to diplay a simple date serie (date, value) with matplotlib and I have a strange problem when using the date autoformater tool on the x-avis
Here is the Python code:
data = pd.read_excel("12-Diffusion_Pyrates/Parties_Pyrates.xlsx",header = 0, sheet_name="Parties_Pyrates")
data['_date'] = pd.to_datetime(data['_date'])
data.sort_values(by='_date', ascending=False, inplace = True)
print(data)
dates = data["_date"]
values = data["_count"]
month_locator = mdates.MonthLocator(interval=1)
ax.xaxis.set_major_locator(month_locator) # Locator for major axis only.
year_month_formatter = mdates.DateFormatter("%m-%Y") # four digits for year, two for month
ax.xaxis.set_major_formatter(year_month_formatter) # formatter for major axis only
fig.autofmt_xdate()
ax.plot(dates,values)
plt.savefig("12-Diffusion_Pyrates/Images/dateHistogram.png", dpi=300)
Here is the result: generated figure
As one can see, one date isn't rotated (10-2021).
Does anyone have an idea how to solve this problem?
I'm looking for an idea to solve this problem