I would like to draw some violin plots with ggplot2, but I noticed that median and first and third quartile are not automatically displayed. I believe these plots would be much more informative with this information. Does anybody know of a way to do it?
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.
geom_violin.Rd. A violin plot is a compact display of a continuous distribution. It is a blend of geom_boxplot() and geom_density() : a violin plot is a mirrored density plot displayed in the same way as a boxplot.
One way to do this is to just put a thin box plot over the top of it. Here's an example with the iris data:
require(ggplot2) ggplot(iris,aes(Species,Sepal.Length))+geom_violin()+geom_boxplot(width=.1)
geom_violin
has an argument draw_quantiles
that allows you to specify which quantiles to include. Here is an example of 1st, 2nd, and 3rd quartiles on iris.
require(ggplot2) ggplot(iris, aes(Species, Sepal.Length)) + geom_violin(draw_quantiles = c(0.25, 0.5, 0.75))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With