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])
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?
I had a problem with the answer by @mwaskorn, namely that
fails, because this also requires the labels. A bit easier than the answer by @Aman is to just add
If anyone wonders how to this for clustermap CorrGrids (part of a given seaborn example):
Aman is correct that you can use normal matplotlib commands, but this is also built into the
FacetGrid
:There are some comments and another answer claiming this "doesn't work", however, anyone can run the code as written here and see that it does work. The other answer does not provide a reproducible example of what isn't working, making it very difficult to address, but my guess is that people are trying to apply this solution to the output of functions that return an
Axes
object instead of aFacet Grid
. These are different things, and theAxes.set_xticklabels()
method does indeed require a list of labels and cannot simply change the properties of the existing labels on theAxes
. The lesson is that it's important to pay attention to what kind of objects you are working with.This is still a matplotlib object. Try this:
For a
seaborn.heatmap
, you can rotate these using (based on @Aman's answer)