This geom is based on the source code of ' geom_hline and geom_vline.

geom_hvline(
  mapping = NULL,
  data = NULL,
  position = "identity",
  show.legend = FALSE,
  ...
)

Arguments

mapping

The aesthetic mapping, usually constructed with aes or aes_string. Only needs to be set at the layer level if you are overriding the plot defaults.

data

A layer specific dataset - only needed if you want to override the plot defaults.

position

The position adjustment to use for overlapping points on this layer

show.legend

should a legend be drawn? (defaults to FALSE)

...

other arguments passed on to layer. This can include aesthetics whose values you want to set, not map. See layer for more details.

Value

a geom_hvline layer

Details

The goal is to determine the line to be either vertial or horizontal based on the 1-d data provided in this layer.

Aesthetics

@section Aesthetics: geom_vline() understands the following aesthetics (required aesthetics are in bold):

  • xintercept

  • alpha

  • colour

  • group

  • linetype

  • size

Learn more about setting these aesthetics in vignette("ggplot2-specs").

Examples

p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() # vline p + geom_hvline(data = data.frame(wt= 3))
# hline p + geom_hvline(data = data.frame(mpg= 20))