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.
| Element | What it encodes | How to read it |
|---|---|---|
| Outline width | Estimated density at each value | Wider means more observations nearby |
| Central white dot or line | Median | Middle value of the group |
| Thick inner bar | Interquartile range | Middle 50 percent of the data |
| Thin inner line | Whiskers or full range | Spread excluding or including extremes |
| Tails of the violin | Minimum and maximum density support | Extent of the observed or smoothed data |
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.
| Parameter | Typical options | Effect on the chart |
|---|---|---|
| Bandwidth | Scott, Silverman or a manual factor | Controls smoothness versus detail |
| Cut or trim | Trim at data range or extend tails | Prevents density beyond real values |
| Scale | Equal area, equal width or by count | Changes how group sizes appear |
| Inner display | Box, quartile lines, points or none | Adds summary statistics or raw data |
| Split | Two halves for two subgroups | Compares paired categories side by side |
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.
| Chart | Shows shape | Shows exact quantiles | Best use |
|---|---|---|---|
| Violin plot | Yes, smoothed | Yes, with inner box | Comparing shapes across several groups |
| Box plot | No | Yes | Quick summaries and outlier detection |
| Histogram | Yes, binned | No | Detailed view of one distribution |
| Strip or swarm plot | Partly, through raw points | No | Small samples where every point matters |
| Ridgeline plot | Yes, smoothed | Rarely | Many groups or time slices in sequence |
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.
| Situation | Recommended chart | Reason |
|---|---|---|
| Several groups, hundreds of points each | Violin plot | Density estimates are stable and comparable |
| Fewer than about 30 points per group | Strip plot or box plot with points | KDE invents shape from too little data |
| Suspected bimodal data | Violin plot with narrow bandwidth | Reveals separate peaks |
| Executive or public audience | Box plot or bar chart with intervals | Simpler encoding is easier to read |
| Discrete values such as ratings 1 to 5 | Stacked bar chart | Smoothing between integers is meaningless |
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.