GeomDistribution | R Documentation |
Computes and draws a probability density function as a continuous curve.
geom_distribution( mapping = NULL, data = NULL, stat = "distribution", position = "identity", ..., fill = NA, outline.type = "upper", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) stat_distribution( mapping = NULL, data = NULL, geom = "ribbon", position = "identity", ..., fun, xlim = NULL, n = 500, p_limit = 0.001, location = 0, fill = NA, alpha = 0.3, outline.type = "upper", color = "black", size = 0.5, args = list(), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
Ignored by |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
fill |
Color of fill under the curve. No fill ( |
outline.type |
Type of the outline of the area; |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use display the data |
fun |
Function to use. A quoted or character name referencing a probability density function; see examples. Must be vectorised. |
xlim |
Optionally, restrict the range of the function to this range. |
n |
Number of points to interpolate along the main body of the probability density. |
p_limit |
The lower probability density limit to plot. |
location |
Where to shift the origin. For probability density functions that do not inherently allow for changing their location, this allows that shift. |
alpha |
Fill color transparency, if applicable. |
color |
Color of the line. |
size |
Size of the line. |
args |
List of additional arguments passed on to the function defined by |
geom_distribution()
understands the following aesthetics (required aesthetics are in bold):
x
or y
ymin
or xmin
ymax
or xmax
alpha
colour
fill
group
linetype
size
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
stat_distribution()
computes the following variables:
x values along a grid where the probability density is at least p_limit
value of the probability density function evaluated at corresponding x
# geom_distribution() is useful for overlaying probability distributions set.seed(1234) ggplot(data.frame(x = rnorm(100)), aes(x)) + geom_density() + geom_distribution(fun = dnorm, color = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.