If you do not want your line to expand across the entire plot range, or if you want to add arbitrary line segments, use segments
. For example, the following code draws a square:
plot.new() plot.window(xlim = c(0, 3), ylim = c(0, 3)) segments(x0=c(1,1,2,2), x1=c(1,2,2,1), y0=c(1,2,2,1), y1=c(2,2,1,1))
source share