Here's code from kaggle Titanic competition kernel:
grid = sns.FacetGrid(train_df, row='Embarked', size=2.2, aspect=1.6)
grid.map(sns.pointplot, 'Pclass', 'Survived', 'Sex', palette='deep')
grid.add_legend()
It produces wrong plot, the one with reversed colors. I'd like to know how to fix this exact code fragment. I tried adding keyword paramas to grid.map() call - order=["male", "female"], hue_order=["male", "female"]
, but then plots become empty.
In the code call to
grid.map(sns.pointplot, 'Pclass', 'Survived', 'Sex', palette='deep')
, the x category is thePclass
and the hue category is theSex
. Hence you need to addComplete example (where I took the titanic that ships with seaborn - what wordplay!):
Note that while
hue_order
is definitely required, you may leave out theorder
. While this will throw a warning, the correct order is garantied by the fact that those values are numerical and are hence automatically sorted.