0

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?

Programming Noob
  • 1,232
  • 3
  • 14
  • Have you tried `plt.xticks(rotation=45)` ? Maybe [this](https://stackoverflow.com/questions/26540035/rotate-label-text-in-seaborn-factorplot) post is useful. – ComputingVictor Dec 18 '22 at 11:15
  • 1
    With `ax = sns.boxplot(...)`, you can use `ax.tick_params(axis='x', rotation=90)` – JohanC Dec 18 '22 at 11:32

1 Answers1

1

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.

Paschalis Ag
  • 128
  • 6