Wednesday, November 21, 2012
Linear plot with intercept and slope in R
# http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/abline.html # http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/plot.html # Set up coordinate system plot(c(-2,3), c(-1,5), type="n", xlab="x", ylab="y", main="y = 2x + 1") # Set up the x- and y-axis abline(h=0, v=0, col="gray60") # Set up a grid abline(h = -1:5, v = -2:3, col = "lightgray", lty=3) # Draw a line with slope=2 and y-intercept=1 abline(b=2, a=1, col="red")