I'm trying to add lines to an existing plot.
Just ignore the data that is not plotted.
geom_abline lets me add lines but they go through the whole graph.
How can I crop the lines that they are only plotted e.g. between (0,0) and (10,-10)?
library(ggplot2)
x <- c(2,4,6,4,7,5,3)
y <- c(4,5,6,7,8,6,4)
data <- data.frame(cbind(x,y))
ggplot(data, aes(x= x, y= y)) +
expand_limits(y = c(25, -60), x = c(20,-5)) +
geom_abline(intercept = 0, slope = -1) +
geom_abline(intercept = 0, slope = -.5, linetype="dotted")