在DataFrame中,我有一个列"Datum2",其中包含我想用作xtick标签的日期为64的日期(YYYYMMDD).我目前的情节看起来是这样的:
我想更改标签以显示年份和月份的缩写(例如,2022年、11月、12月、2023年、1月、2月等).
目前我有这样的代码:
import seaborn as sns
import matplotlib.pyplot as plt
import scipy.stats as stats
import numpy as np
df_tagesspiegel_final['Datum2'] = pd.to_datetime(df_tagesspiegel_final['Datum'], format='%Y%m%d')
# Scatterplot erstellen
sns.scatterplot(x='Datum2', y = 'compound', data=df_tagesspiegel_final)
#Quintile als xticks speichern
xticks = [df_tagesspiegel_final['Datum2'].min(), df_tagesspiegel_final['Datum'].median(numeric_only=True), df_tagesspiegel_final['Datum'].max()]
plt.gca().set(xticks=xticks, xlabel='Datum', ylabel='compound', title='Compound-Sentiment im Zeitverlauf')
plt.show()
How would I go about formatting the dates accordingly?
I feel like this might be a start https://matplotlib.org/stable/api/dates_api.html#matplotlib.dates.ConciseDateConverter
but to be honest, I am very new to python and I'm in way over my head