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

2
  • 3
    You simply cannot plot 100 categories in a bar chart. Try getting the top 10. Commented Mar 30, 2020 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 Commented Mar 30, 2020 at 13:35

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.