Line, horizontal
The following aesthetics can be used with geom_hline. They are listed along with their default value. All geoms and scales can also use the group aesthetic. Read how this important aesthetic works in scale_group. Typically, you will associate an aesthetic with a variable in your data set. To do this, you use the aes function: geom_hline(aes(x = var))
. Scales control the details of the mapping between data and aesthetic properties; after each aesthetic are listed scales that can be used with that aesthetic. The scale documentation will also provide references to help you interpret the default values.
Instead of mapping an aesthetic to a variable in your dataset, you can also set it to a fixed value. See the parameters section for details.
colour: black
(scales: brewer, gradient, gradient2, hue, manual)
size: 1
(scales: area, manual, size, size_discrete)
intercept: 0
When an aesthetic is used an a parameter, like geom_hline(colour = 3)
, it will override mappings from data.
colour
, border coloursize
, sizelinetype
, line typeintercept
, x/y interceptstat_identity. Override with the stat
argument: geom_hline(stat="identity")
position_identity. Override with the position
argument: geom_hline(position="jitter")
.
> p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point() > > p + geom_hline(intercept=20)> p + geom_hline(intercept=seq(10, 30, by=5))
> p + geom_hline(intercept=mean(mtcars$mpg), size=2)
![]()