Rotate tick labels for seaborn barplot
Use the following code statement:
by_school.set_xticklabels(by_school.get_xticklabels(),
rotation=90,
horizontalalignment='right')
You need a different method call, namely .set_rotation
for each ticklable
s.
Since you already have the ticklabels, just change their rotations:
for item in by_school.get_xticklabels():
item.set_rotation(45)
barplot
returns a matplotlib.axes
object (as of seaborn
0.6.0), therefore you have to rotate the labels this way. In other cases, when the method returns a FacetGrid
object, refer to Rotate label text in seaborn factorplot
If you come here to rotate the labels for a seaborn.heatmap
, the following should work (based on @Aman's answer at Rotate label text in seaborn factorplot)
pandas_frame = pd.DataFrame(data, index=names, columns=names)
heatmap = seaborn.heatmap(pandas_frame)
loc, labels = plt.xticks()
heatmap.set_xticklabels(labels, rotation=45)
heatmap.set_yticklabels(labels[::-1], rotation=45) # reversed order for y
You can rotate seaborn xticks like so:
sns.barplot(x='Organization Name', y='Score', data=df)
plt.xticks(rotation=70)
plt.tight_layout()