-1

I'd like to avoid text overlapping in the next graphic:

import matplotlib.pyplot as plt
import seaborn as sns

bar_barris = sns.countplot(y=df2['Nom_Barri'])

bar_barris.set_yticklabels(bar_barris.get_yticklabels(), rotation=40, ha="right")
plt.show()

The output of the code is as follows:

enter image description here

edachan
  • 33
  • 2
  • 5

1 Answers1

0

I found the answer to my own question: the size of the figure needs to be defined before plotting.

plt.figure(figsize=(10, 18)) # To make the y axis higher, increase the second parameter (18)

bar_barris = sns.countplot(y=df2['Nom_Barri'])

bar_barris.set_yticklabels(bar_barris.get_yticklabels(), rotation=40, ha="right")
plt.show()

Result: enter image description here

edachan
  • 33
  • 2
  • 5