Violin plot

On this page 7

A violin plot is a chart that displays the distribution of a numeric variable as a symmetric, mirrored kernel density estimate, usually with summary statistics such as the median and quartiles drawn inside it. In data visualization, it combines the compact summary of a box plot with the shape information of a histogram, which makes it well suited to comparing distributions across several groups.

The width of the violin at any value is proportional to how many observations lie near that value. Wide sections mark common values, narrow sections mark rare ones, and separate bulges reveal multiple modes that a box plot would hide completely.

How a violin plot is constructed

A violin plot is built by estimating a smooth density curve for each group, mirroring it around a central axis and filling the resulting outline. The density comes from kernel density estimation (KDE), which places a small bell-shaped kernel, usually Gaussian, on every observation and sums them into one continuous curve.

Most implementations then overlay a miniature box plot or markers for the median and interquartile range, so the reader sees both the exact summary and the overall shape. The vertical axis carries the measured values, while the horizontal axis lists the groups being compared.

Each visual element of the chart encodes a specific property of the data, as the table below summarizes.

ElementWhat it encodesHow to read it
Outline widthEstimated density at each valueWider means more observations nearby
Central white dot or lineMedianMiddle value of the group
Thick inner barInterquartile rangeMiddle 50 percent of the data
Thin inner lineWhiskers or full rangeSpread excluding or including extremes
Tails of the violinMinimum and maximum density supportExtent of the observed or smoothed data
Visual elements of a violin plot

Bandwidth and other key parameters

The single most influential setting in a violin plot is the KDE bandwidth, which controls how much each observation is smoothed. A small bandwidth produces a jagged outline that follows noise, while a large bandwidth produces a smooth blob that can erase real bimodality.

Default bandwidths usually come from rules of thumb such as Scott’s rule or Silverman’s rule, which assume roughly normal data. They work well for unimodal samples but tend to oversmooth skewed or multimodal distributions, so analysts often test a narrower bandwidth before publishing a chart.

ParameterTypical optionsEffect on the chart
BandwidthScott, Silverman or a manual factorControls smoothness versus detail
Cut or trimTrim at data range or extend tailsPrevents density beyond real values
ScaleEqual area, equal width or by countChanges how group sizes appear
Inner displayBox, quartile lines, points or noneAdds summary statistics or raw data
SplitTwo halves for two subgroupsCompares paired categories side by side
Main violin plot parameters and their effects

The scale setting deserves special attention. With equal-area scaling, a group of 20 observations looks as substantial as a group of 20,000, which can mislead readers unless sample sizes are labeled on the axis.

Violin plot compared with box plots and histograms

A violin plot sits between the box plot and the histogram: it shows more shape than a box plot and fits more groups on one chart than separate histograms. Choosing among these neighbors in the Visualization topic depends on the audience and on what the comparison must reveal.

ChartShows shapeShows exact quantilesBest use
Violin plotYes, smoothedYes, with inner boxComparing shapes across several groups
Box plotNoYesQuick summaries and outlier detection
HistogramYes, binnedNoDetailed view of one distribution
Strip or swarm plotPartly, through raw pointsNoSmall samples where every point matters
Ridgeline plotYes, smoothedRarelyMany groups or time slices in sequence
Distribution charts compared

A frequent compromise is the violin plus raw points design, sometimes called a raincloud plot when the density appears on one side and jittered points on the other. It keeps the smooth shape while proving to the reader how much data supports it.

When to use a violin plot

A violin plot is the right choice when distribution shape matters to the conclusion, for example when groups have similar medians but different spread, skew or number of peaks. It is less useful for general audiences who are not familiar with density charts.

SituationRecommended chartReason
Several groups, hundreds of points eachViolin plotDensity estimates are stable and comparable
Fewer than about 30 points per groupStrip plot or box plot with pointsKDE invents shape from too little data
Suspected bimodal dataViolin plot with narrow bandwidthReveals separate peaks
Executive or public audienceBox plot or bar chart with intervalsSimpler encoding is easier to read
Discrete values such as ratings 1 to 5Stacked bar chartSmoothing between integers is meaningless
Deciding whether a violin plot fits

Violin plots are available in most analysis tools, including seaborn and Matplotlib in Python, ggplot2 in R and custom builds in D3.js, so implementation effort is rarely the deciding factor.

Limitations and common misreadings

The main limitation of a violin plot is that the outline is an estimate, not the data. Smoothing can draw density in places where no observations exist, and readers may treat these artifacts as real findings.

  • Tails beyond the data range: untrimmed KDE extends below zero for values such as prices or durations that cannot be negative.
  • Hidden sample size: equal-area scaling makes tiny and large groups look equally reliable.
  • Mirror redundancy: the two halves carry identical information, so the chart uses twice the ink for one curve.
  • Bandwidth sensitivity: different defaults across libraries can make the same data look unimodal or bimodal.
  • Unfamiliar encoding: many readers interpret width as a range or a confidence band rather than as density.

Good practice is to trim the density to the observed range, annotate group sizes, state the bandwidth method in a caption and overlay raw points when samples are small.

In everyday language

Picture a crowd of people standing along a measuring tape according to their height. Where many people have similar heights, the crowd is thick; where few people stand, it thins out. If you draw the outline of that crowd and copy it as a mirror image, you get the shape of a violin.

A violin plot shows where values pile up and where they are rare. Putting several violins next to each other lets you compare groups at a glance and spot whether one group has two separate clusters instead of one.

Seen in the real world

A product analytics team at a food delivery service wants to compare delivery times across four city districts. Each district has between 3,000 and 9,000 orders per month. The average delivery time is similar everywhere, about 32 minutes, so a bar chart of means suggests nothing is wrong.

The analysts draw a violin plot with one violin per district, trimmed to the observed range and with an inner box showing quartiles. Three violins have a single bulge around 30 minutes, but the fourth has two distinct peaks, one near 22 minutes and another near 45 minutes.

Investigation shows that the fourth district is split by a river, and orders crossing the only bridge take much longer. The team adds a second courier hub on the far bank, and two months later the violin for that district shows a single peak near 28 minutes.