This is my example code and output.
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# Create a DataFrame with a date column and another column with the data you want to plot
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
df['Date'] = pd.to_datetime(df['Date'])
# Create a Matplotlib plot using the date data for the x-axis and the 'Value' column for the y-axis data
plt.plot(df['Date'], df['Value'], marker='o', linestyle='-')
plt.xlabel('Date')
plt.ylabel('Y-axis Label')
plt.title('Your Plot Title')
Can I set x-axis format like belows?
I want to display yy.m
only on the first day of each year and m
for the rest.