Using Seaborn, I'm trying to generate a factorplot with each subplot showing a stripplot. In the stripplot, I'd like to control a few aspects of the markers.
Here is the first method I tried:
import seaborn as sns
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col="time", hue="smoker")
g = g.map(sns.stripplot, 'day', "tip", edgecolor="black",
linewideth=1, dodge=True, jitter=True, size=10)
And produced the following output without dodge

While most of the keywords were implemented, the hue wasn't dodged.
I was successful with another approach:
kws = dict(s=10, linewidth=1, edgecolor="black")
tips = sns.load_dataset("tips")
sns.factorplot(x='day', y='tip', hue='smoker', col='time', data=tips,
kind='strip',jitter=True, dodge=True, **kws, legend=False)
This gives the correct output:

In this output, the hue is dodged.
My question is: why did g.map(sns.stripplot...) not dodge the hue?
The
hueparameter would need to be mapped to thesns.stripplotfunction via theg.map, instead of being set ashueto theFacetgrid.This is because
mapcallssns.stripplotindividually for each value in thetimecolumn, and, ifhueis specified for the completeFacetgrid, for each hue value, such thatdodgewould loose its meaning on each individual call.I can agree that this behaviour is not very intuitive unless you look at the source code of
mapitself.Note that the above solution causes a Warning:
I honestly don't know what this is telling us; but it seems not to corrupt the solution for now.