0
I’m trying to plot a regression graph where the date interval is in year format, but I can’t centralize the data on the X axis. The chart range below is between 2016 and 2020.
plt.figure(figsize=(13,9))
ax = sns.regplot(data=dados_de_carga, x='data_ordinal', y='media_carga',scatter_kws={"color": "black"},line_kws={"color": "red"})
# Tighten up the axes for prettiness
ax.set_xlim(dados_de_carga['data_ordinal'].min() - 2, dados_de_carga['data_ordinal'].max() + 2)
ax.set_ylim(0, dados_de_carga['media_carga'].max() + 2)
ax.set_xlabel('')
new_labels = dados_de_carga['data_de_distribuicao'].dt.strftime('%Y')
ax.set_xticklabels(new_labels)
plt.ylabel('Média de carga')