stat_overlay_normal_density {ggpubr} | R Documentation |
Overlay Normal Density Plot
Description
Overlay normal density plot (with the same mean and SD) to the density distribution of 'x'. This is useful for visually inspecting the degree of deviance from normality.
Usage
stat_overlay_normal_density(
mapping = NULL,
data = NULL,
geom = "line",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
na.rm |
If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
other arguments to pass to |
See Also
Examples
# Simpledensity plot
data("mtcars")
ggdensity(mtcars, x = "mpg", fill = "red") +
scale_x_continuous(limits = c(-1, 50)) +
stat_overlay_normal_density(color = "red", linetype = "dashed")
# Color by groups
data(iris)
ggdensity(iris, "Sepal.Length", color = "Species") +
stat_overlay_normal_density(aes(color = Species), linetype = "dashed")
# Facet
ggdensity(iris, "Sepal.Length", facet.by = "Species") +
stat_overlay_normal_density(color = "red", linetype = "dashed")