Plot Line in Intercept-Slope Form

DESCRIPTION:

Adds a line to a plot, often a regression line.

USAGE:

abline(a, b) 
abline(coef) 
abline(reg) 
abline(h=, v=) 

REQUIRED ARGUMENTS:

one of the forms below must be specified.
a,b
intercept and slope as above.
coef
vector containing the intercept a and slope b of the line y= a+ b*x.
reg
a regression object, such as returned by lsfit. Specifically, reg$coef, if it is of length 2, will be used to define the intercept and slope of the line. If reg$coef is of length 1, it is treated as the slope of a fit through the origin. The first two elements are used if reg$coef has length greater than 2.
h=
vector of y-coordinates for horizontal lines across plot. Missing values are not accepted.
v=
vector of x-coordinates for vertical lines across plot. Missing values are not accepted.

OPTIONAL ARGUMENTS:

Graphical parameters may also be supplied as arguments to this function (see ).

SIDE EFFECTS:

The effect of abline is that the line y= a+ b*x or the specified horizontal and vertical lines are drawn across the current plot. A warning is given if a line does not intersect the plot.

DETAILS:

abline is a generic function; currently there is only the default method available.

SEE ALSO:

, , .

EXAMPLES:

# line with 0 intercept and slope 1 
abline(0, 1) 
# line produced by least-squares fit 
abline(lsfit(longley.x[, 1], longley.y)) 
# dotted vertical lines at x==0 and 10 
abline(v = c(0, 10), lty = 2)