2

I am attempting to superimpose dot plots on top of a bar graph. Both types of plots have been generated using seaborn's catplot function.

Scatter-plot Code:

dotplot2 = sns.catplot(x="Group", y="MASQ_Score", col= "MASQ_Item", units="subject", aspect=.6, hue="Group", ci = 68, data=df_reshaped)

Resulting Plot Image:

Scatter-plot

Bar-plot Code:

barplot2 = sns.catplot(x="Group", y="MASQ_Score", hue='Group', kind="bar", col= "MASQ_Item", units="subject", aspect=.6, ci = 68, data=df_reshaped)

Resulting Plot Image:

Bar-Plot

Does anyone know if there is a way to superimpose the scatter-plot data on top of the bar-plot? So that both types of information are conveniently visible.

Derek O
  • 16,770
  • 4
  • 24
  • 43
arkadiy
  • 746
  • 1
  • 10
  • 26

2 Answers2

2

Based on @ImportanceOfBeingErnest comment, here is a working solution with open data using the map_dataframe method from FacetGrid:

import seaborn as sns
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col="time")
g.map_dataframe(sns.stripplot,x="sex", y="total_bill")
g.map_dataframe(sns.boxplot,x="sex", y="total_bill",boxprops={'facecolor':'None'},showfliers = False)

Output result

The stirpplot and boxplot can easily be replaced by other seaborn components like swarmplot or violinplot.

0

What you are plotting is not a scatter plot, it is a stirpplot. As @Rachid Riad shows. If what you are looking for is to make a barplot instead of a boxplot, you just have to change that line to:

sns.barplot()

I would personally recommend using boxplot and swarmplot.

juan trinidad
  • 130
  • 2
  • 3