Rotate the xlabels with seaborn

Question:

I’ve made a boxplot, but as you see the xlabels are too long so I need to rotate them a little bit:

enter image description here

I’ve found several topics for this, here on stack, and on other sites. Some of my tries and the errors I got:

long_box.set_xticklabels(long_box.get_xticklabels(),rotation=30)

or

plt.setp(long_box.get_xticklabels(), rotation=45)

give this error:

AttributeError: 'Text' object has no attribute 'set_xticklabels'

and, this code long_box.tick_params(axis='x', labelrotation=90)

produces this error:

AttributeError: 'Text' object has no attribute 'tick_params'

I didn’t understand what does a ‘Text’ object mean.. how do I fix this?

Asked By: Programming Noob

||

Answers:

Have you tried the plt.xticks(rotation=45) after you define the graph?

In addition to that have a look here since there are a lot of tips on how to do that.

Answered By: Paschalis Ag
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.