EVOLUTION-MANAGER
Edit File: abline.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Add Straight Lines to a Plot</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for abline {graphics}"><tr><td>abline {graphics}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add Straight Lines to a Plot</h2> <h3>Description</h3> <p>This function adds one or more straight lines through the current plot. </p> <h3>Usage</h3> <pre> abline(a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL, coef = NULL, untf = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>a, b</code></td> <td> <p>the intercept and slope, single values.</p> </td></tr> <tr valign="top"><td><code>untf</code></td> <td> <p>logical asking whether to <em>untransform</em>. See ‘Details’.</p> </td></tr> <tr valign="top"><td><code>h</code></td> <td> <p>the y-value(s) for horizontal line(s).</p> </td></tr> <tr valign="top"><td><code>v</code></td> <td> <p>the x-value(s) for vertical line(s).</p> </td></tr> <tr valign="top"><td><code>coef</code></td> <td> <p>a vector of length two giving the intercept and slope.</p> </td></tr> <tr valign="top"><td><code>reg</code></td> <td> <p>an object with a <code><a href="../../stats/html/coef.html">coef</a></code> method. See ‘Details’.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p><a href="par.html">graphical parameters</a> such as <code>col</code>, <code>lty</code> and <code>lwd</code> (possibly as vectors: see ‘Details’) and <code>xpd</code> and the line characteristics <code>lend</code>, <code>ljoin</code> and <code>lmitre</code>.</p> </td></tr> </table> <h3>Details</h3> <p>Typical usages are </p> <pre>abline(a, b, untf = FALSE, \dots) abline(h =, untf = FALSE, \dots) abline(v =, untf = FALSE, \dots) abline(coef =, untf = FALSE, \dots) abline(reg =, untf = FALSE, \dots) </pre> <p>The first form specifies the line in intercept/slope form (alternatively <code>a</code> can be specified on its own and is taken to contain the slope and intercept in vector form). </p> <p>The <code>h=</code> and <code>v=</code> forms draw horizontal and vertical lines at the specified coordinates. </p> <p>The <code>coef</code> form specifies the line by a vector containing the slope and intercept. </p> <p><code>reg</code> is a regression object with a <code><a href="../../stats/html/coef.html">coef</a></code> method. If this returns a vector of length 1 then the value is taken to be the slope of a line through the origin, otherwise, the first 2 values are taken to be the intercept and slope. </p> <p>If <code>untf</code> is true, and one or both axes are log-transformed, then a curve is drawn corresponding to a line in original coordinates, otherwise a line is drawn in the transformed coordinate system. The <code>h</code> and <code>v</code> parameters always refer to original coordinates. </p> <p>The <a href="par.html">graphical parameters</a> <code>col</code>, <code>lty</code> and <code>lwd</code> can be specified; see <code><a href="par.html">par</a></code> for details. For the <code>h=</code> and <code>v=</code> usages they can be vectors of length greater than one, recycled as necessary. </p> <p>Specifying an <code>xpd</code> argument for clipping overrides the global <code><a href="par.html">par</a>("xpd")</code> setting used otherwise. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p>Murrell, P. (2005) <em>R Graphics</em>. Chapman & Hall/CRC Press. </p> <h3>See Also</h3> <p><code><a href="lines.html">lines</a></code> and <code><a href="segments.html">segments</a></code> for connected and arbitrary lines given by their <em>endpoints</em>. <code><a href="par.html">par</a></code>. </p> <h3>Examples</h3> <pre> ## Setup up coordinate system (with x == y aspect ratio): plot(c(-2,3), c(-1,5), type = "n", xlab = "x", ylab = "y", asp = 1) ## the x- and y-axis, and an integer grid abline(h = 0, v = 0, col = "gray60") text(1,0, "abline( h = 0 )", col = "gray60", adj = c(0, -.1)) abline(h = -1:5, v = -2:3, col = "lightgray", lty = 3) abline(a = 1, b = 2, col = 2) text(1,3, "abline( 1, 2 )", col = 2, adj = c(-.1, -.1)) ## Simple Regression Lines: require(stats) sale5 <- c(6, 4, 9, 7, 6, 12, 8, 10, 9, 13) plot(sale5) abline(lsfit(1:10, sale5)) abline(lsfit(1:10, sale5, intercept = FALSE), col = 4) # less fitting z <- lm(dist ~ speed, data = cars) plot(cars) abline(z) # equivalent to abline(reg = z) or abline(coef = coef(z)) ## trivial intercept model abline(mC <- lm(dist ~ 1, data = cars)) ## the same as abline(a = coef(mC), b = 0, col = "blue") </pre> <hr /><div style="text-align: center;">[Package <em>graphics</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>