View source: R/geom_violinhalf.R
geom_violinhalf | R Documentation |
Create a half-violin plot.
geom_violinhalf(
mapping = NULL,
data = NULL,
stat = "ydensity",
position = "dodge",
trim = TRUE,
flip = FALSE,
scale = c("area", "count", "width"),
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 |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
trim |
If |
flip |
Should the half-violin plot switch directions? By default, this
is |
scale |
if "area" (default), all violins have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all violins have the same maximum width. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to
|
library(ggplot2)
library(see)
ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
geom_violinhalf() +
theme_modern() +
scale_fill_material_d()
# To flip all half-violin geoms, use `flip = TRUE`:
ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
geom_violinhalf(flip = TRUE) +
theme_modern() +
scale_fill_material_d()
# To flip the half-violin geoms for the first and third groups only
# by passing a numeric vector
ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
geom_violinhalf(flip = c(1, 3)) +
theme_modern() +
scale_fill_material_d()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.