Skip to content

Violin Plots

What is a violin plot?

A violin plot combines:

  • A KDE distribution shape
  • A box-plot-like summary inside

It’s useful when you want to see the shape of distributions (multi-modal, skew).

diagram Violin = box plot + KDE mermaid
A violin plot mirrors a KDE curve left and right to form a shape, with a mini box plot drawn down the middle.

Violin plot in Seaborn

Violin plot
import seaborn as sns
import matplotlib.pyplot as plt
 
tips = sns.load_dataset("tips")
 
plt.figure(figsize=(7, 4))
sns.violinplot(data=tips, x="day", y="total_bill")
plt.title("Total bill distribution by day")
plt.tight_layout()
plt.show()
Violin plot
import seaborn as sns
import matplotlib.pyplot as plt
 
tips = sns.load_dataset("tips")
 
plt.figure(figsize=(7, 4))
sns.violinplot(data=tips, x="day", y="total_bill")
plt.title("Total bill distribution by day")
plt.tight_layout()
plt.show()

Add inner summary

Violin with inner quartiles
import seaborn as sns
import matplotlib.pyplot as plt
 
tips = sns.load_dataset("tips")
 
plt.figure(figsize=(7, 4))
sns.violinplot(data=tips, x="day", y="total_bill", inner="quartile")
plt.title("Violin plot with quartiles")
plt.tight_layout()
plt.show()
Violin with inner quartiles
import seaborn as sns
import matplotlib.pyplot as plt
 
tips = sns.load_dataset("tips")
 
plt.figure(figsize=(7, 4))
sns.violinplot(data=tips, x="day", y="total_bill", inner="quartile")
plt.title("Violin plot with quartiles")
plt.tight_layout()
plt.show()

Visualize it

The width of the violin at any height shows how common values near that height are — wider means more data points cluster there:

sketch Anatomy of a violin plot p5.js
The violin's width at each height mirrors the KDE density; the inner bar is a mini box plot.

When to prefer violin vs box

  • Use box plots for quick comparisons and outlier focus.
  • Use violin plots when the distribution shape matters.

Next

Continue to Bar Plots in Seaborn to compare an aggregated value (like a mean) across categories, with confidence intervals.

🧪 Try It Yourself

Exercise 1 – A Basic Violin Plot

Exercise 2 – Show Quartiles Inside

Exercise 3 – Box vs Violin

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did