You may add additional horizontal and vertical lines to a plot by using the abline function. This will allow you to create a customized grid or to show one or several important points or limits within you plot.
The following example creates a plot and adds some horizontal and vertical lines by using the abline function with the h or v argument.
x <- c(1,2,3,4,5,6)
y <- c(3,6,9,4,3,4)
plot(x,y, type = ‚l‘, lty = ’solid‘, lwd = 2)
abline(h = 4, lty = ‚dashed‘, col = ‚gray‘)
abline(h = 6, lty = ‚dashed‘, col = ‚gray‘)
abline(h = 8, lty = ‚dashed‘, col = ‚gray‘)
abline(v = 2, lty = ‚dashed‘, col = ‚gray‘)
abline(v = 3.5, lty = ‚dashed‘, col = ‚gray‘)
abline(v = 5, lty = ‚dashed‘, col = ‚gray‘)
Pingback: Data visualization in R: Grid | coders corner