0

I am plotting some variables but the data labels are a bit long so they are overlapping. I would like them to be displayed in multiple lines. The code I am using is this:

lista = list(df['col'].unique())
sns.countplot(data = df,x = 'col').set_xticklabels( lista,wrap=True)
sns.despine()
plt.show()

Seaborn plot

  • You can add newlines into the data, e.g. `df['col'] = df['col'].replace('Planchado y Pintar', 'Planchado\ny Pintar').replace('Mantenimiento Periodico', 'Mantenimiento\nPeriodico').replace(..., ....)` and then plot. You need to be careful with `set_xticklabels( lista)` because the order of `lista` could be different from the order of the x axis. – JohanC Nov 24 '21 at 22:02

0 Answers0