0

I'm looking to combine a barplot with a swarmplot in seaborn, when using the "col" feature of a catplot.

I am aware that this question was asked before in seaborn overlap swarmplot on barplot, but this solution does not work for me. I want to make multiple subplots (using "col"). So when I try their solution, all datapoints of the swarmplot are plotted on the last subplot, and not on the corresponding subplot:

import seaborn as sns
tips = sns.load_dataset("tips")
g = sns.catplot(x="sex", y="total_bill",
                hue="smoker", col="time",
                data=tips, kind="bar",
                height=4, aspect=.7);
sns.swarmplot(x="sex", y="total_bill", data=tips,dodge=True)

Result

I have also tried the following, using map_dataframe:

g = sns.catplot(x="sex", y="total_bill",
                hue="smoker", col="time",
                data=tips, kind="bar",
                height=4, aspect=.7);
g.map_dataframe(sns.swarmplot,"sex","total_bill","smoker")

but here, the result doesn't look correct either (for each bar, I want the corresponding points on there)

How can I get the datapoints on the corresponding subplot & bar? The color can be black, but I just want to get an idea of the distribution of the points.

Robindp
  • 1
  • 1

0 Answers0