geom_hline
and geom_abline
for other types of
lines.geom_vline(mapping = NULL, data = NULL, stat = "vline",
position = "identity", show_guide = FALSE, ...)
aes
or aes_string
. Only needs to be set
at the layer level if you are overriding the plot defaults.FALSE
)# With coordinate transforms p + geom_vline(aes(xintercept = wt)) + coord_equal() p + geom_vline(aes(xintercept = wt)) + coord_flip() p + geom_vline(aes(xintercept = wt)) + coord_polar()
p2 <- p + aes(colour = factor(cyl)) p2 + geom_vline(xintercept = 15)
# To display different lines in different facets, you need to # create a data frame. p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am) vline.data <- data.frame(z = c(15, 20, 25, 30), vs = c(0, 0, 1, 1), am = c(0, 1, 0, 1)) p + geom_vline(aes(xintercept = z), vline.data)
geom_hline
for horizontal lines,
geom_abline
for lines defined by a slope and intercept,
geom_segment
for a more general approach"