geom_vlinegeom_vline(mapping=NULL, data=NULL, stat="vline", position="identity", ...)
Line, vertical
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.
What do you think of the documentation? Please let me know by filling out this short online survey.
The following aesthetics can be used with geom_vline. Aesthetics are mapped to variables in the data with the aes function: geom_vline(aes(x = var)). Note that you do not need quotes around the variable name.
Scales control how the variable is mapped to the aesthetic and are listed after each aesthetic.
| Aesthetic | Default | Related scales |
|---|---|---|
| colour | black | brewer, gradient, gradient2, gradientn, grey, hue, identity, manual |
| size | 0.5 | identity, manual, size |
| linetype | 1 | identity, linetype, manual |
| alpha | 1 |
Layers are divided into groups by the group aesthetic. By default this is set to the interaction of all categorical variables present in the plot.
Parameters control the appearance of the geom. 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.
This function returns a layer object.
> # 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")
> > last_plot() + coord_equal()
> last_plot() + coord_flip()
> > p2 <- p + aes(colour = factor(cyl)) > p2 + geom_vline(xintercept = 15)
![]()
What do you think of the documentation? Please let me know by filling out this short online survey.