What is a Violin Plot?
A violin plot combines a box plot with a kernel density estimation (KDE) mirrored on each side, showing the full distribution shape — not just summary statistics. The width of the violin at any point represents the relative density of data values, revealing patterns a box plot alone cannot show.
Why Use Violin Plots?
- Reveal multi-modal distributions. Unlike box plots, violin plots show when your data has multiple peaks.
- Compare shape, spread, and density. Place violin plots side by side to compare the entire distributional shape across groups.
- Combine with box plot elements. This tool overlays the five-number summary inside the violin.
Frequently Asked Questions
What does a violin plot show?
How is a violin plot different from a box plot?
Key Terms
- KDE
- Kernel Density Estimation — a non-parametric way to estimate the probability density function.
- Bandwidth
- Controls the smoothness of the KDE curve. Smaller = finer detail; larger = smoother.
- Minimum (Min)
- The smallest data point excluding outliers.
- First Quartile (Q1)
- The median of the lower half. 25% of data falls below Q1.
- Median (Q2)
- The middle value. 50% of data falls below the median.
- Third Quartile (Q3)
- The median of the upper half. 75% of data falls below Q3.
- Maximum (Max)
- The largest data point excluding outliers.
- Interquartile Range
- Q3 − Q1. Measures statistical spread.
Computation Method
- Quartiles are calculated using linear interpolation (method 7 from Hyndman & Fan, 1996), consistent with Python's NumPy and pandas defaults.
- Outlier detection uses the Tukey fences method: lower fence = Q1 − 1.5 × IQR, upper fence = Q3 + 1.5 × IQR.
- Chart scaling caps the display axis at the upper fence value so the visualization remains clear even when extreme outliers are present.
References
- Hintze, J. L. & Nelson, R. D. (1998). "Violin Plots: A Box Plot-Density Trace Synergism." The American Statistician, 52(2), 181–184.
- Tukey, J. W. (1977). Exploratory Data Analysis. Addison-Wesley.
- Scott, D. W. (2015). Multivariate Density Estimation: Theory, Practice, and Visualization. 2nd ed. Wiley.