Add horizontal line to ggplot() for specified interval of x axis
ggplot2, r
Solution
You can use `geom_segment()` to add line segment with your own defined starting and ending points (not only horizontal/vertical lines).
ggplot(mtcars,aes(mpg,qsec))+geom_point()+
geom_segment(aes(x=15,xend=20,y=18,yend=18))
Problem
I would like to add horizontal lines to an existing plot, but I would only like to plot the line for certain intervals of the x-axis. For example I would like to have a horizontal line at X=1:5 and y=50. I would use `existing_plot+geom_hline(yintercept = 50)` Is it also possible to specify the x values somehow?