Violin plots should not exist
Science 100 years ago was wild. If you wanted a plot in your paper, you’d have to draw it by hand, mail it in to a journal who would have to find a way to print it. The further you go back in time the less you see anything that isn’t standard typewritten text. It was easier to include tables summarizing the data and explain salient features as part of your text.
In the 50’s and 60’s, ok, there are photocopiers.
In the 80’s and 90’s we had programs to do data visualization. Plots could be regenerated easily if a mistake was spotted. But distributing plots might still be tedious (floppy disks sent over snail mail?). Because journals were printed, the cost of using color was a meaningful factor.
Screenshot at [3:19] shows submission information for some journal. Inclusion of color figures in the online version of the journal is free, but for the print version of the journal to include color figures, author must pay 350GBP charge for the first page with color and 150GBP for every page with color thereafter.
So, there were all sorts of barriers to creation, reproduction, and distribution of data visualization that are now not issues, and there is substantially less selective pressure on bad data visualizations. This leads to an embarrassment of riches.
[3:45] Plots can be bad because they’re misleading: pie charts that don’t add to 100, scales that exaggerate tiny differences by not going to 0.
Plots can be unsuited for the audience. Most people have poor intuition of logarithms, so log plots aren’t a great choice for the general public. There can even be plots where the implications aren’t clear to people not in the field.
The violin plot was introduced in a paper in 1998, titled “Violin Plots: A Box Plot-Density Trace Synergism” by Jerry Hintze and Ray Nelson.
First, I find it very interesting how in the 90’s you could get a publication by just being like, “We made a new type of plot. Cite us every time you use this plot. It’s our plot. The violin plot.” Very silly.
It’s a combination of two plots.
- A box plot (or box plot with whiskers), which encodes the min, max, median, and the upper and lower quartiles
- A kernel density plot, which is like a histogram but smoothed to act as an estimate of the PDF your samples were taken from
In a violin plot, you mirror the kernel density plot around a box plot. It looks like this (below image from sthda.com, CC BY-NC-SA 3.0):
[7:37]
Opinion: aesthetically these are ugly and hard to read.
How do you read these?
- A box plot talks about the average of the dataset, usually you use it to show a trend among different classes/groupings of samples.
- A density distribution is used when your distribution is wonky and it doesn’t make sense to talk about one central point or spread from that point. e.g., a multimodal distribution.
So the violin plot mainly combines two plots where, if one is useful, it’s guaranteed that the other one is at best useless or at worst distracting.
[9:15] sample plot from the 1998 paper
The lynchpin of their paper is showing two boxplots that are identical but whose density plots are very different (because bimodal distributions), meaning that the violin plot is more useful than the box plot alone. But this is a false dichotomy: you could just plot histograms. And put the averages in a table, if that also matters.
Also, with the violin plot, where are the units? Usually, density distributions are normalized to 1, with an axis that makes that clear, but almost no violin plots include the axis for their density distribution. Are they normalized? Are they all scaled the same?
If you want to understand a violin plot and understand the density distributions relative to one another, you have to assume they’re scaled the same, take the image, chop the mirrored density distribution in half, rotate, and then place them above each other.
These violin plots are purely for aesthetics, which, I mean, inappropriate for a science paper, but also, like, really? You can’t actually get data, you’re just getting vibes. And that doesn’t belong in a scientific paper.
[12:00]
People who use violin plots seem to treat them as pretty but useless–even if only subconsciously. Because even when an author includes a violin plot, they also include one of the other two types of plots (or a substitute thereof).
This brings me to the point of smoothing. In the past, making a histogram required great care. The smoothing you used was an analytical decision which colors your conclusions, and so including a histogram without disclosing these was a big no-no. Yet with violin plots somehow this is tolerated and normalized (see example at [14:43] of same dataset as violin plot with two different smoothings).
[17:28]
My biggest argument, my proof, that these are bad is that any time you see a violin plot, you can instantly make it better by unmaking the violin plot.
Example: a dataisbeautiful plot, characterizing same sex marriage laws in the USA by state and year. The legal status is characterized by one of 4 classes, and the density is percentage of states. It’s an animated violin plot where the plot is updated to show changes from 1995 to 2015.
If you take the exact same plot, to just be a smoothed histogram (not mirrored), animated in the same way, with the same data, it is much much clearer. Because you are taking up half the real estate to communicate the same data.
And in fact, when the data is center stage over aesthetic, it’s more obvious how weird the smoothing is. The 4 classes representing legal status of same sex marriage are not fuzzy, so the smoothing doesn’t make sense. Moreover, with only 50 states and clear yes/no membership to the classes, smoothing didn’t really make sense in the first place.
What is better?
If the shape of the data is important, use a histogram, with axes, units, numbers, and disclosure of bin-widths and how/why you arrived at those bin-widths.
One option is to stack histograms (with transparency). Or, plot the densities overlaid (with transparency).
If you want something that looks cool, use a 3D histogram. Or upgrade to a ridgeline plot.
If you like violin plots, but harder to read, you can consider bean plots. Rather than embedding a box plot inside, you drop tickmarks or dots for every data point.
I’m begging you to understand, that’s literally what a histogram is. That’s what the histogram shows, why would you put every single data point in, it makes no sense. Fine.
It’s hard to look at a bunch of data points, why are they all there. The point of the histogram is so that you can get the information without having to have your brain figure it out, ‘cause that’s hard for brains to do. That’s the point of the histogram. Why would you shove all the points on top.
[24:11]
And of course, there are also asymmetric violin and bean plots, which are the same thing except with one extra dimension and a lot more difficulty comparing the unitless density plots.
Every time you make a plot, you need to ask, “what is this trying to say?”. Readers typically scan papers somehow to decide whether to read in-depth, and for lots of readers that’s scanning the abstract, plots, then conclusion.
This is what your paper is going to be remembered as, and this doesn’t say anything.
[26:35]
These plots look like vulvas. And that’s fine. Unfortunately, academia has a lot of young people, STEM in particular has a big gender gap, and STEM has a lot of people with bad social skills. So it is correlated with some unfortunate situations which make women feel uncomfortable.
In the end, this is not the reason to avoid violin plots. Violin plots should be avoided because they are bad at communicating data, which is ostensibly their goal. This is just a cherry on top.
[37:17]
Unlike real vulvas, the flaps on violin plots are always symmetric. There is no reason for this second flap to exist. Why are you copying the histogram over, that makes the plot more convoluted.
Removing the 2nd flap turns a violin plot into a ridgeline plot with boxplot, except rotated. Not only does that remove extra clutter–which frees up a bunch of space you could use to make your plot smaller or use the space productively.
The core task a density plot helps with is comparing density at various points along the curve, but with mirroring that’s harder anyway. Comparing the widths of two objects is harder if they’re centered than if they are left or right-aligned.