I'm trying to change the labels in a violin plot on Seaborn. I wanna change the NU_NOTA_CN, NU_NOTA_CH, NU_NOTA_LC, NU_NOTA_MT and NU_NOTA_REDAÇÃO, and TP_ESCOLA, and the 2 and 3.
import pandas as pd
import numpy as np
import seaborn as sns
fig_dims = (10, 8)
fig, ax = plt.subplots(figsize=fig_dims)
sns.boxplot(x="DISCIPLINA", y="NOTA", hue="TP_ESCOLA", data=publica_privada_pivot)
plt.show()
plt.clf()
plt.close()
You can use the set_xticklabels
f, ax = plt.subplots()
sns.boxplot(x="DISCIPLINA", y="NOTA", hue="TP_ESCOLA", data=publica_privada_pivot, ax=ax)
ax.set_xticklabels([...]) # list of strings
In addition, you can use get_xticklabels
, for example.
xticklabels = [t.get_text() for t in ax.get_xticklabels()]
xticklabels = [t.replace('NU_', '').replace('_', ' ').title()
ax.set_xticklabels(xticklabels)