HAHS.
Back to Catalog

Violin Plot

chart

Also known as: density plot, mirrored density, violin chart

Show distributionCompareShow deviation NumericalCategorical Bar/Column

Description

A violin plot combines the information of a box plot with a kernel density estimate (KDE), creating a mirrored, smoothed density shape for each category. The width of the “violin” at any point along the value axis represents the estimated probability density of data at that value. Wider sections indicate higher concentrations of data points, while narrow sections indicate sparse regions. This shape immediately reveals features that box plots conceal: bimodality, skewness, heavy tails, and gaps in the distribution.

Each violin is typically symmetric (mirrored on both sides of a central axis), though split violins can show two sub-groups side by side within a single violin shape. Many implementations overlay a miniature box plot or individual data points inside the violin to provide the familiar quartile summary alongside the density information.

Violin plots shine when comparing distributions across categories where shape matters as much as center and spread. They are particularly valuable in scientific and statistical communication where the audience needs to understand the full distributional story rather than just a five-number summary.

Violin Plot — interactive example

When to Use

  • Comparing the shape of distributions across multiple groups, not just center and spread
  • Revealing bimodal or multimodal distributions that box plots would hide
  • Showing the density of data at different values (where observations concentrate)
  • Presenting statistical results to an audience comfortable with density estimation

When NOT to Use

  • When you have very small sample sizes (fewer than 20 per group) — the KDE will oversmooth and the shape will be misleading; use a strip plot or box plot with jittered points
  • When the audience is unfamiliar with density plots — a histogram or box plot may communicate more clearly
  • When you need to show exact percentiles or outlier values — pair with a box plot overlay or use a box plot alone
  • When you have many categories (>15) — the display becomes cluttered; consider faceting or a ridgeline plot

Anatomy

  • Density shape (violin body): The mirrored KDE curve showing the estimated distribution, wider where data is dense
  • Central marker: Often a small box plot (box + median line) or a single point for the median
  • Whiskers or IQR indicators: Optional lines inside the violin marking quartiles or percentile ranges
  • Category axis: Groups arranged along one axis
  • Value axis: The continuous measurement scale
  • Bandwidth parameter: Controls smoothness of the KDE (not visible, but critical to the shape)

Variations

  • Split violin: Each half shows a different sub-group (e.g., male vs. female), enabling direct within-category comparison
  • Violin + jittered points: Raw data points are scattered inside the violin to show sample size and individual values
  • Violin + box plot: A miniature box plot is drawn inside each violin, combining both representations
  • Ridgeline plot (joy plot): Overlapping density plots stacked vertically, useful when there are many categories and you want to show distribution shape compactly
  • Bean plot: Similar to violin but includes individual data points as small lines and a bold line for the mean

Code Reference

// D3-based violin with density estimation
import * as Plot from "@observablehq/plot";

// Observable Plot doesn't have a native violin mark,
// but you can build one with the density and area marks:
Plot.plot({
  y: {grid: true},
  facet: {data, x: "category"},
  marks: [
    Plot.areaY(data, Plot.binX({y: "count"}, {
      x: "value", fill: "category", curve: "basis"
    })),
    Plot.ruleY([0])
  ]
})