geom_vline {ggplot2}R Documentation

geom_vline

Description

Line, vertical

Usage

geom_vline(mapping=NULL, data=NULL, stat="vline", 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 vertical lines (see geom_hline 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_vline, 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_vline. Aesthetics are mapped to variables in the data with the aes function: geom\_vline(\code{aes}(x = var))

Author(s)

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

See Also

Examples

## Not run: 
# Fixed lines
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + geom_vline(xintercept = 5)
p + geom_vline(xintercept = 1:5)
p + geom_vline(xintercept = 1:5, colour="green")
p + geom_vline(xintercept = "mean", size=2, colour = alpha("red", 0.2))

last_plot() + coord_equal()
last_plot() + coord_flip()

# Lines from data
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + geom_vline(xintercept = "mean") + facet_grid(. ~ cyl)
p + geom_vline(aes(colour = factor(cyl)), xintercept = "mean")
## End(Not run)

[Package ggplot2 version 0.8.2 Index]