| stat_function {ggplot2} | R Documentation |
Superimpose a function
stat_function(mapping = NULL, data = NULL, geom = "path", position = "identity",
fun, n = 101, args = list(), ...)
mapping |
mapping between variables and aesthetics generated by aes |
data |
dataset used in this layer, if not specified uses plot dataset |
geom |
geometric used by this layer |
position |
position adjustment used by this layer |
fun |
function to use |
n |
number of points to interpolate along |
args |
list of additional arguments to pass to fun |
... |
other arguments |
This page describes stat\_function, see layer and qplot for how to create a complete plot from individual components.
A layer
The following aesthetics can be used with stat\_function. Aesthetics are mapped to variables in the data with the aes function: stat\_function(aes(x = var))
y: y position
Hadley Wickham, http://had.co.nz/
## Not run: x <- rnorm(100) base <- qplot(x, geom="density") base + stat_function(fun = dnorm, colour = "red") base + stat_function(fun = dnorm, colour = "red", arg = list(mean = 3)) ## End(Not run)