I have two sub categories 'Stage 10' and 'Stage 13' under the main category 'Control'.
I want to show the value dots with stripplot
. The problem is that the value dots now are at the middle between the two violins. But I want the dots to be on each violin. How can I do it?
My current violin plot looks like the attached image.
My code is:
sns.violinplot(data=transposed_df, x="Genotype", y="Normalized_PGC", hue="Stage", inner=None)
sns.stripplot(data=transposed_df, x="Genotype", y="Normalized_PGC", jitter=True, color='black', size=5)
You can represent observations as points inside the distribution by setting inner="point"
in the arguments, then you don't even need to add a stripplot:
sns.violinplot(data=transposed_df, x="Genotype", y="Normalized_PGC", hue="Stage", inner="point")
With simple synthetic data it should look like this
x = np.random.normal(0,2,100)
y = ['A' if val < 0 else 'B' for val in x]
df = pd.DataFrame({'val' : x, 'label' : y})
sns.violinplot(data=df, x="label", y="val", inner="point")
Output: