stat_function {ggplot2}R Documentation

stat\_function

Description

Superimpose a function

Usage

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

Arguments

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

Details

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

Value

A layer

Aesthetics

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))

Author(s)

Hadley Wickham, http://had.co.nz/

See Also

Examples

## 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)

[Package ggplot2 version 0.8.9 Index]