Provide an example `seaborn.violinplot` call using `hue`.
Oct 3, 12:15am

This is a small snippet, so here it is inline:

python
import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.violinplot(
    data=tips,
    x="day",
    y="total_bill",
    hue="sex",
    split=True,        # draw half-violins for each hue level
    inner="quart",
    palette="pastel",
)

plt.show()

Key points:

  • hue="sex" splits each x="day" category into two violins (one per hue level).
  • split=True overlays them as mirrored half-violins (only recommended when hue has exactly 2 levels).
  • In seaborn ≥ 0.13, prefer passing data= with column names, and palette requires hue (which it has here). Use hue="sex", legend=False instead of the older hue + palette + dodge pattern if you only want coloring.
Oct 3, 12:15am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more