How can I add a straight line form (5, 5) to infinity to this plot? I use abline but I do not want the line between 5 to 5, just I need after 5 to infinity.
x <- c(1:5); y <- x
plot(x, y, type="l")
abline(v= max(x), col="black", lwd=2, lty=2)
How can I add a straight line form (5, 5) to infinity to this plot? I use abline but I do not want the line between 5 to 5, just I need after 5 to infinity.
x <- c(1:5); y <- x
plot(x, y, type="l")
abline(v= max(x), col="black", lwd=2, lty=2)
You can use segments
and par('usr')
to extract the existing axis limits. I've used lty=1
to show that it wil extend to the edge of the plotting area
plot(x,y,type = 'l')
segments(x0 = max(x), y0 = max(y), y1 = par('usr')[4], lwd=2)