Split violins in the sea with a hue setting

I am trying to do violinplotusing only the parameters yand huein seaborn(the xdata variable is defined as None). Using a similar example, as in the documentation I did:

tips = sns.load_dataset("tips")
sns.violinplot(y="total_bill", hue="sex", data=tips, split=True)

And the final figure is not divided according to the hue variable.

enter image description here

When the variable x is defined, the graph is broken. Is there a way to have a split plot in the seabed without typing x?

+4
source share
1 answer

Just add a variable that will be the same for all records, and use it like x:

tips = sns.load_dataset("tips")
tips["all"] = ""
ax = sns.violinplot(x="all", y="total_bill", hue="sex", data=tips, split=True)
ax.set_xlabel("")

enter image description here

+11
source

Source: https://habr.com/ru/post/1616126/


All Articles