Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
For horizontal and vertical lines, use geom_hline() and
geom_vline(), and for angled lines, use geom_abline()
(Figure 7-7). For this example, we’ll use the
heightweight data set:
library(gcookbook)# For the data setp<-ggplot(heightweight,aes(x=ageYear,y=heightIn,colour=sex))+geom_point()# Add horizontal and vertical linesp+geom_hline(yintercept=60)+geom_vline(xintercept=14)# Add angled linep+geom_abline(intercept=37.4,slope=1.75)