geom_hline {ggplot2}R Documentation

geom_hline

Description

Line, horizontal

Usage

geom_hline(mapping=NULL, data=NULL, stat="hline", position="identity", ...)

Arguments

mapping mapping between variables and aesthetics generated by aes
data dataset used in this layer, if not specified uses plot dataset
stat statistic used by this layer
position position adjustment used by this layer
... ignored

Details

This geom allows you to annotate the plot with horizontal lines (see geom_vline and geom_abline for other types of lines)

There are two ways to use it. You can either specify the intercept of the line in the call to the geom, in which case the line will be in the same position in every panel. Alternatively, you can supply a different intercept for each panel using a data.frame. See the examples for the differences

This page describes geom_hline, 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 geom_hline. Aesthetics are mapped to variables in the data with the aes function: geom\_hline(\code{aes}(x = var))

Author(s)

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

See Also

Examples

## Not run: 
p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point()

p + geom_hline(aes(yintercept=mpg))
p + geom_hline(yintercept=20)
p + geom_hline(yintercept=seq(10, 30, by=5))
p + geom_hline(yintercept="mean")
p + geom_hline(aes(colour=factor(cyl)), yintercept="mean")
## End(Not run)

[Package ggplot2 version 0.8.2 Index]