stat_function

stat_function(mapping=NULL, data=NULL, geom="path", position="identity", fun, n=101, args=list(), ...)

Superimpose a function

This page describes stat_function, see layer and qplot for how to create a complete plot from individual components.

What do you think of the documentation? Please let me know by filling out this short online survey.

New variables produced by the statistic

To use these variables in an aesthetic mapping, you need to surrond them with .., like aes(x = ..output..). This tells ggplot that the variable isn't the original dataset, but has been created by the statistic.

Parameters

Parameters control the appearance of the stat. In addition to the parameters listed below (if any), any aesthetic can be used as a parameter, in which case it will override any aesthetic mapping.

Returns

This function returns a layer object.

Examples

> x <- rnorm(100) 
> qplot(x, geom="density") + stat_function(fun = dnorm, colour="red") 
  

What do you think of the documentation? Please let me know by filling out this short online survey.