Create split violin plot with ggplot2 with geom_split_violin. Shamelessly copy-pasted from jan-glx at Stack Overflow.
geom_split_violin( mapping = NULL, data = NULL, stat = "ydensity", position = "identity", ..., draw_quantiles = NULL, trim = TRUE, scale = "area", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping | Set of aesthetic mappings created by |
---|---|
data | The data to be displayed in this layer. There are three options: If A A |
stat | A value |
position | Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... | Other arguments passed on to |
draw_quantiles | A value |
trim | A value |
scale | A value |
na.rm | A value |
show.legend | logical. Should this layer be included in the legends?
|
inherit.aes | If |
set.seed(123) my_data = tibble::tibble( x=c(rep('a', 200), rep('b', 200)), y=c(rnorm(100), rnorm(100, 0.5), rnorm(100, 1), rnorm(100, 1.5)), cond=c(rep('i', 100), rep('j', 200), rep('i', 100)) ) ggplot2::ggplot(my_data, ggplot2::aes(x, y, fill=cond)) + geom_split_violin()