I would like to overlap a swarmplot on a barplot with seaborn. Let's generate my kind of data (3 conditions, with 3 replicates each, at 3 timepoints) :
condition_list = []
experiment_list = []
day_list = []
result_list = []
for condition in ['A', 'B', 'C']:
for experiment in range(1,4):
for day in range(1,4):
condition_list.append(condition)
experiment_list.append(experiment)
day_list.append(day)
result_list.append(random.random())
datas = list(zip(condition_list,experiment_list,day_list,result_list))
df = pd.DataFrame(data=datas, columns=['Condition','Experiment','Day','Result'])
I am fine with the barplot :
sns.catplot(x="Condition", y="Result", hue='Day', data=df, kind="bar", ci='sd')
But if I want to add corresponding values as dots on this figure, they are all aligned on the same abscissa :
sns.catplot(x="Condition", y="Result", hue='Day', data=df, kind="bar", ci='sd')
sns.swarmplot(x="Condition", y="Result", hue='Day', data=df)
Here is my problem ! For each bar, I would like to plot as dots the three corresponding values.
For example, if we restrain datas for the first day, I can plot bars AND dots on the same figure :
new_df = df[df['Day'] == 1].reset_index(drop=True)
sns.barplot(x="Condition", y="Result", data=new_df, ci="sd")
sns.swarmplot(x="Condition", y="Result", color='black',data=new_df, zorder=10)
Is it possible to do the same on the first figure with seaborn ? Thank you very much for your help ^^