0

enter image description hereI don't know why my barplot is not ordered in the right sequence. I would like to start from the oldest date to the newest.

cl['DATE OF CONTACT']=pd.to_datetime(cl['DATE OF CONTACT']).dt.date    
sns.set(style="whitegrid", context="talk")
plt.figure(figsize=(15,10))
plt.rc('xtick', labelsize=20) 
plt.rc('ytick', labelsize=20) 

ax=sns.countplot(cl['DATE OF CONTACT'])
ax.set_xticklabels(ax.get_xticklabels(),rotation=90)
for p in ax.patches:
    ax.annotate(format(p.get_height(), '.2f'), 
               (p.get_x() + p.get_width() / 2., 
                p.get_height()), ha = 'center', 
               va = 'center', xytext = (0, 10), 
               textcoords = 'offset points')

thanks for the help.

Babbbu95
  • 17
  • 4
  • Welcome to Stack Overflow! Please take a moment to read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). You need to provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) that includes a toy dataset (refer to [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)) – Diziet Asahi Nov 10 '20 at 14:32
  • Why don't you sort before plotting: `cl = cl.sort_values(['DATE OF CONTACT'])`? – Parfait Nov 10 '20 at 16:32

0 Answers0