data = {'Date': ['2023-01-01', '2023-02-01', '2023-03-01', '2024-01-01', '2024-02-01'],
'Value': [10, 15, 13, 18, 20]}
df = pd.DataFrame(data)
# Convert the 'Date' column to datetime.date which results in the labels being centered under the xticks
df['Date'] = pd.to_datetime(df['Date']).dt.date
# plot the data
ax = df.plot(x='Date', rot=0, figsize=(7, 5))
# format the major ticks
ax.xaxis.set_major_formatter(mdates.DateFormatter('%y.%m'))
ax.xaxis.set_major_locator(mdates.MonthLocator(bymonth=1, interval=1))
# format the minor ticks
ax.xaxis.set_minor_locator(mdates.MonthLocator())
ax.xaxis.set_minor_formatter(mdates.DateFormatter("%m"))
ax.xaxis.set_minor_locator(mdates.MonthLocator(bymonth=[3, 5, 7, 9, 11]))