Violin plot

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Example of a violin plot
Example of a violin plot in a scientific publication in PLOS Pathogens.

A violin plot is a method of plotting numeric data. It is similar to a box plot, with the addition of a rotated kernel density plot on each side.[1]

Violin plots are similar to box plots, except that they also show the probability density of the data at different values, usually smoothed by a kernel density estimator. Typically a violin plot will include all the data that is in a box plot: a marker for the median of the data; a box or marker indicating the interquartile range; and possibly all sample points, if the number of samples is not too high.

Recently it was shown that the violin plot called Mirrored Density plot (MD plot) outperforms conventional violin plots in terms of the identification of interesting structures in data in the programming languages of R and Python.[2] Violin plots are available as extensions to a number of software packages such as DataVisualization on CRAN [3] and the md-plot package on PyPI.[4]

A violin plot is more informative than a plain box plot. While a box plot only shows summary statistics such as mean/median and interquartile ranges, the violin plot shows the full distribution of the data. The difference is particularly useful when the data distribution is multimodal (more than one peak). In this case a violin plot shows the presence of different peaks, their position and relative amplitude.

Like box plots, violin plots are used to represent comparison of a variable distribution (or sample distribution) across different "categories" (for example, temperature distribution compared between day and night, or distribution of car prices compared across different car makers).

A violin plot can have multiple layers. For instance, the outer shape represents all possible results. The next layer inside might represent the values that occur 95% of the time. The next layer (if it exists) inside might represent the values that occur 50% of the time.

Although more informative than box plots, they are less popular. Because of their unpopularity, their meaning can be harder to grasp for many readers not familiar with the violin plot representation. In this case, a more accessible alternative can be plotting a series of stacked histograms or kernel density distributions.

Violin plots are available as extensions to a number of software packages, including the R packages vioplot, wvioplot, caroline, UsingR, lattice and ggplot2, the Stata add-on command vioplot,[5] and the Python libraries matplotlib,[6] Plotly,[7] ROOT[8] and Seaborn,[9] a graph type in Origin,[10] IGOR Pro,[11] Julia statistical plotting package StatsPlots.jl[12] and DistributionChart in Mathematica.


  1. ^ "Violin Plot". NIST DataPlot. National Institute of Standards and Technology. 2015-10-13.
  2. ^ Thrun, Michael C.; Gehlert, Tino; Ultsch, Alfred (2020-10-14). Vafaee, Fatemeh (ed.). "Analyzing the fine structure of distributions". PLOS ONE. 15 (10): e0238835. doi:10.1371/journal.pone.0238835. ISSN 1932-6203.
  3. ^ "CRAN - Package DataVisualization".
  4. ^ "md-plot . PyPI".
  5. ^ Hintze, Jerry L.; Nelson, Ray D. (1998). "Violin Plots: A Box Plot-Density Trace Synergism". The American Statistician. 52 (2): 181–4. doi:10.1080/00031305.1998.10480559.
  6. ^ "violin plots". What's new in matplotlib.
  7. ^ "Violin Plots in Python". Plotly Python API Library Reference.
  8. ^ "The Violin option". Retrieved 2020-05-05.
  9. ^ Waskom, Michael. "Violinplot from a wide-form dataset". Seaborn: statistical data visualization.
  10. ^ "Violin Plot in Origin 2019". Retrieved 2018-10-29.
  11. ^ "Igor Pro 8 Highlights". Wavemetrics. Retrieved 2019-07-28.
  12. ^ "boxplot, dotplot, and violin". Retrieved 2020-08-15.

External links[edit]

Public Domain This article incorporates public domain material from the National Institute of Standards and Technology document: "Dataplot reference manual: Violin plot".