10
$\begingroup$

What would you call this type of plot, and is it possible to create them in R?

EDIT: many thanks all - very helpful.

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ Looks like a bunch of population pyramid charts. $\endgroup$ – Mateen Ulhaq Feb 3 '16 at 19:37
  • 6
    $\begingroup$ Could you please explain how these plots work? What quantities do they represent and precisely how do they represent them? Without such information we could all be giving different answers to different interpretations of the question, which might leave everybody confused. $\endgroup$ – whuber Feb 3 '16 at 21:29
  • 3
    $\begingroup$ @whuber's pertinent questions remain unanswered, which is very disappointing. But as I far as I can see these are just histograms side-by-side with centered (centred) bars. It's a clear majority convention to plot histograms with vertical bars, and a fairly common minority convention to show horizontal bars, but the logic of a histogram is seemingly followed here, namely that bar areas encode frequencies. Centred bars are quite common in archaeology and ecology. $\endgroup$ – Nick Cox Feb 4 '16 at 16:43
  • $\begingroup$ @whuber My presumption is that we are to read these plots like histograms, and that this format is an alternative to overlaying histograms which allows us to compare means but at the same time visualise the distribution. So in that sense it's an extension of the box plot too. $\endgroup$ – bjw Feb 5 '16 at 18:41
  • 1
    $\begingroup$ How are means shown here? Or medians and quartiles? We are still lacking a source. Please give a reference and/or give the explanation provided with the original. $\endgroup$ – Nick Cox Feb 5 '16 at 18:51
11
$\begingroup$

Sorry I don't have enough street cred on CV to post a comment, where this is more appropriate, but here is a link to some code in R to perform something like what you've depicted, using base graphics to rotate histograms in place of the density function inherent in ggplot2:

from stack overflow: https://stackoverflow.com/questions/15846873/symmetrical-violin-plot-like-histogram

if someone with appropriate powers cares to move this from answer to comment, please do.

$\endgroup$
3
  • $\begingroup$ Don't sell yourself short. This does answer the second half of the question: "is it possible to create them in R?" $\endgroup$ – shadowtalker Feb 3 '16 at 21:52
  • $\begingroup$ yay! I can comment - thanks for the support. Was trying to abide by rules and not just post a link, but if it helps someone, that's all that's important $\endgroup$ – JasonD Feb 3 '16 at 22:02
  • $\begingroup$ @Jason You can always comment on your own posts. I expect you'll be able to comment everywhere quite soon. $\endgroup$ – Glen_b Feb 3 '16 at 22:59
16
$\begingroup$

It's a little hard to tell what the plots are supposed to represent, but they look an awful lot like violin plots.

A violin plot is essentially a vertical, doubled kernel density plot, so that the width along the x axis corresponds to greater density at the corresponding value along the y axis.

You can generate them in package lattice with panel.violin, or in ggplot2 with geom_violin.

Edit: there is also an R package called vioplot that (I think) uses only base R graphics, and a package called beanplot that generates something similar called a "bean plot."

$\endgroup$
10
  • 7
    $\begingroup$ Let's call it quantized violin plots :) $\endgroup$ – Franck Dernoncourt Feb 3 '16 at 16:57
  • $\begingroup$ I build something similar but starting from a box plot - the "boxes" where not constant but represented the poportion of cases within that area $\endgroup$ – Christian Sauer Feb 4 '16 at 9:09
  • $\begingroup$ Many thanks for this... I upvoted you but felt I had to accept the other answer as it actually showed how to do it in R, but I actually prefer bean plots now I've seen them, so thanks. $\endgroup$ – bjw Feb 4 '16 at 14:50
  • 1
    $\begingroup$ I'd advise against the violin plot terminology here, as the density estimation element is quite missing and that's not a widely known term in any case. $\endgroup$ – Nick Cox Feb 4 '16 at 16:43
  • $\begingroup$ @nickcox ... aren't density plots just smoothed histograms? $\endgroup$ – bjw Feb 5 '16 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.