0

Bar plot x axis is getting very messy , I have also rotated the angle but it is still very messy any help would be appreciated.

this is the code

ax=yearresult.plot(kind='bar',x='BBB',y='AAA')
ax.set_xticklabels(ax.get_xticklabels(), rotation=90)
ax.legend(["AAA", "BBB"]);
plt.tight_layout()
plt.show()

enter image description here

Tayyab Vohra
  • 1,512
  • 3
  • 22
  • 49
  • 3
    You simply cannot plot 100 categories in a bar chart. Try getting the top 10. – Erfan Mar 30 '20 at 12:00
  • I'm pretty sure, that you should think about representing the data in a different way, if you *really* need everything to be seen – user8408080 Mar 30 '20 at 13:35

1 Answers1

0

you cannot plot 100 categories in a bar chart it will not be clear. Try getting the top 15 like this:

 top_15 = df.AA.value_counts().iloc[:15]
 sns.countplot(x = "AA", data = df, order=top_15.index);

and no need for legend in that case