View source: R/geom_half_violin.R
geom_half_violin | R Documentation |
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.
geom_half_violin( mapping = NULL, data = NULL, stat = "half_ydensity", position = "dodge", ..., side = "l", nudge = 0, draw_quantiles = NULL, trim = TRUE, scale = "area", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) stat_half_ydensity( mapping = NULL, data = NULL, geom = "half_violin", position = "dodge", ..., bw = "nrd0", adjust = 1, kernel = "gaussian", 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 |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
side |
The side on which to draw the half violin plot. "l" for left, "r" for right, defaults to "l". |
nudge |
Add space between the violinplot and the middle of the space allotted to a given factor on the x-axis. |
draw_quantiles |
If |
trim |
If |
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. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom, stat |
Use to override the default connection between
|
bw |
The smoothing bandwidth to be used.
If numeric, the standard deviation of the smoothing kernel.
If character, a rule to choose the bandwidth, as listed in
|
adjust |
A multiplicate bandwidth adjustment. This makes it possible
to adjust the bandwidth while still using the a bandwidth estimator.
For example, |
kernel |
Kernel. See list of available kernels in |
The half-violin plot accepts an optional 'split' aesthethic to compare data separated by a binary variable side-by-side.
Hintze, J. L., Nelson, R. D. (1998) Violin Plots: A Box Plot-Density Trace Synergism. The American Statistician 52, 181-184.
[geom_half_violin()] for examples.
ggplot(iris, aes(x = Species, y = Petal.Width, fill = Species)) + geom_half_violin() ggplot(iris, aes(x = Species, y = Petal.Width, fill = Species)) + geom_half_violin(side = "r") ggplot() + geom_half_violin( data = ToothGrowth, aes(x = as.factor(dose), y = len, split = supp, fill = supp), position = "identity" ) + theme_minimal() ggplot(ToothGrowth, aes(x = supp, y = len, color = supp)) + geom_half_violin(side = c("l", "r")) ggplot(data = ToothGrowth, aes(x = 1, y = len)) + geom_half_point(aes(y = len), side = "l") + geom_half_violin(aes(y = len), side = "r") + coord_flip()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.