EVOLUTION-MANAGER
Edit File: segments.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 Line Segments 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 segments {graphics}"><tr><td>segments {graphics}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add Line Segments to a Plot</h2> <h3>Description</h3> <p>Draw line segments between pairs of points. </p> <h3>Usage</h3> <pre> segments(x0, y0, x1 = x0, y1 = y0, col = par("fg"), lty = par("lty"), lwd = par("lwd"), ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x0, y0</code></td> <td> <p>coordinates of points <b>from</b> which to draw.</p> </td></tr> <tr valign="top"><td><code>x1, y1</code></td> <td> <p>coordinates of points <b>to</b> which to draw. At least one must be supplied.</p> </td></tr> <tr valign="top"><td><code>col, lty, lwd</code></td> <td> <p><a href="par.html">graphical parameters</a> as in <code><a href="par.html">par</a></code>, possibly vectors. <code>NA</code> values in <code>col</code> cause the segment to be omitted.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further <a href="par.html">graphical parameters</a> (from <code><a href="par.html">par</a></code>), such as <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>For each <code>i</code>, a line segment is drawn between the point <code>(x0[i], y0[i])</code> and the point <code>(x1[i], y1[i])</code>. The coordinate vectors will be recycled to the length of the longest. </p> <p>The <a href="par.html">graphical parameters</a> <code>col</code>, <code>lty</code> and <code>lwd</code> can be vectors of length greater than one and will be recycled if necessary. </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> <h3>See Also</h3> <p><code><a href="arrows.html">arrows</a></code>, <code><a href="polygon.html">polygon</a></code> for slightly easier and less flexible line drawing, and <code><a href="lines.html">lines</a></code> for the usual polygons. </p> <h3>Examples</h3> <pre> x <- stats::runif(12); y <- stats::rnorm(12) i <- order(x, y); x <- x[i]; y <- y[i] plot(x, y, main = "arrows(.) and segments(.)") ## draw arrows from point to point : s <- seq(length(x)-1) # one shorter than data arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3) s <- s[-length(s)] segments(x[s], y[s], x[s+2], y[s+2], col= 'pink') </pre> <hr /><div style="text-align: center;">[Package <em>graphics</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>