# How to scale violin plots for comparisons?

I'm trying to draw violin plots and wondering if there is an accepted best practice for scaling them across groups. Here are three options I've tried using the R mtcars data set (Motor Trend Cars from 1973, found here).

## Equal Widths

Seems to be what the original paper does and what R vioplot does (example). Good for comparing shape.

## Equal Areas

Feels right since each plot is a probability plot, and so the area of each should equal 1.0 in some coordinate space. Good for comparing density within each group, but seems more appropriate if the plots are overlaid.

## Weighted Areas

Like equal area, but weighted by number of observations. 6-cyl gets relatively thinner since there are fewer of those cars. Good for comparing density across groups.

-
The purpose of the plots will, to a large extent, determine which solutions are appropriate. What, then, are you trying to show with them? – whuber Jul 27 '11 at 16:11
@whuber Good question, though I don't have a direct answer. I'm trying to provide a graphic for EDA and am looking for a good general default (and whether the other options are useful enough to surface). – xan Jul 27 '11 at 17:18
I would like to suggest that you control the plots to suit your purposes rather than accepting some default. – whuber Jul 29 '11 at 12:50
I would suggest that your "weighted areas" version was "Good for comparing subgroups of a population" since it might make sense to add the widths to get the shape of the whole population. – Henry Aug 29 '11 at 9:33
I prefer equal areas, to preserve the visual impact of shape of distributions. Then supplement the graph with thermometers showing sample sizes, or just use text representations of sample sizes next to violins. – Frank Harrell Feb 2 '14 at 13:32

Box plots are used for schematic summaries of a distribution. The violin plots are just box plots in which the Q1, Q2, and Q3 boxes are replaced by a wide range of quantiles. For that reason, I think the accepted practice is to use uniform width across groups.

However, you bring up a good point: how should densities across groups be compared? The answer depends on whether you are looking at each group as it's own population or as subpopulations.

I think that a useful DEFAULT behavior is to think of the full data as being the density we want to estimate. The groups are subpopulations such that the full density is a MIXTURE of the sub-densities. That suggests that each sub-density should be weighted by the number of observations. The areas (integral of the densities) of the k groups should be P_i, where $\Sigma_i P_i = 1$. This says that "Weighted Areas" is a good approach.

-

Honestly, I think you're approaching it from the wrong direction. All three plots clearly tell you information with value - otherwise, you wouldn't be considering which plot to use. Exploratory data analysis is about understanding your data. Where it conforms to expectation. Where it doesn't. How is it shaped over multiple variables.

The whole point of doing EDA is evaluating whether our defaults, be they distribution or colinearity assumptions, the statistical model that was going to be used, etc. are well justified. As such, the concept of a "default" EDA is somewhat flawed.

Look at all of them - or at least all of the plots that relate to the question you intend to ask. There's no reason to hamstring yourself into "What's interesting" and "What am I going to ignore" at the EDA stage. And if we're just feeding the data through defaults, it's not really EDA in the first place.

-
+1 for enlightening remarks about EDA, although it's still not clear (to me) whether the OP is after EDA or not... – chl Sep 7 '11 at 21:10
@chl Some of the OP's comments suggest that's what he's after. If it is just "which of these is more useful" the answer I fear becomes an even more ambiguous "well, what do you want to show?" – Fomite Sep 7 '11 at 21:15
Ah, I missed that comment... So your response is worth a +1 again, but I cannot :( – chl Sep 7 '11 at 21:17