Reputation: 608
I am trying to make a split violin plot but the plot is never actually split when generated. I have tried following the seaborn guide but I'm not sure what is wrong since it does not produce a 2 colored split violin like in the guide.
My DF looks like this:
Accuracy Train_Time Model
0 0 0.825165 170.013132 LSTM
1 1 0.849305 171.778840 LSTM
2 2 0.826628 174.107146 LSTM
3 3 0.834674 176.774985 LSTM
4 0 0.927944 18.521901 CNN
5 1 0.929042 18.595950 CNN
6 2 0.930139 18.421983 CNN
7 3 0.927213 18.329449 CNN
And my seaborn plot code looks like this:
sns.set_theme(style="whitegrid")
ax = sns.violinplot(y="Accuracy", hue="Model", data=comp_df, palette="Set2", split=True)
plt.show()
Upvotes: 0
Views: 1088
Reputation: 40737
hue
-nesting can only be used in addition to a x
. In your case, you need to create a dummy column with the same value for the whole dataset.
comp_df['dummy'] = 0
ax = sns.violinplot(y="Accuracy", x='dummy', hue="Model", data=comp_df, palette="Set2", split=True)
Upvotes: 2