How To Set Rotation For Seaborn Facetgrid And Figure-level Xtick Labels
I have a dataframe (df) looks like below: import pandas as pd import seaborn as sns data = {'Year': [2010, 2010, 2010, 2011, 2011, 2011, 2019, 2019, 2019], 'Capacity': ['4
Solution 1:
- Specify
g.set_xticklabels(rotation=x)
Updated Answer
- Per
seaborn.FacetGrid
is is now prefered to use use a figure-level functions - Using
seaborn.catplot
seaborn v0.11.0
import pandas as pd
import seaborn as sns
order = ['4,999 and under', '5,000-6,000', '6,100-7,000']
g = sns.catplot(data=df, col='Year', x='Capacity', y='Qty', order=order, kind='bar', col_wrap=3, height=4, aspect=1)
g.set_xticklabels(rotation=90)
Original Answer
import pandas as pd
import seaborn as sns
g = sns.FacetGrid(df, col="Year", col_wrap=3, height=4, aspect=1)
order = ['4,999 and under', '5,000-6,000', '6,100-7,000']
g.map(sns.barplot, "Capacity", "Qty", order=order)
g.set_xticklabels(rotation=90)
Post a Comment for "How To Set Rotation For Seaborn Facetgrid And Figure-level Xtick Labels"