Rotate label text in seaborn factorplot

dan picture dan · Oct 24, 2014 · Viewed 173.7k times · Source

I have a simple factorplot

import seaborn as sns
g = sns.factorplot("name", "miss_ratio", "policy", dodge=.2, 
    linestyles=["none", "none", "none", "none"], data=df[df["level"] == 2])

enter image description here

The problem is that the x labels all run together, making them unreadable. How do you rotate the text so that the labels are readable?

Answer

Gijs picture Gijs · Jan 11, 2016

I had a problem with the answer by @mwaskorn, namely that

g.set_xticklabels(rotation=30)

fails, because this also requires the labels. A bit easier than the answer by @Aman is to just add

plt.xticks(rotation=45)