EVOLUTION-MANAGER
Edit File: polygon.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: Polygon Drawing</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 polygon {graphics}"><tr><td>polygon {graphics}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Polygon Drawing</h2> <h3>Description</h3> <p><code>polygon</code> draws the polygons whose vertices are given in <code>x</code> and <code>y</code>. </p> <h3>Usage</h3> <pre> polygon(x, y = NULL, density = NULL, angle = 45, border = NULL, col = NA, lty = par("lty"), ..., fillOddEven = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y</code></td> <td> <p>vectors containing the coordinates of the vertices of the polygon.</p> </td></tr> <tr valign="top"><td><code>density</code></td> <td> <p>the density of shading lines, in lines per inch. The default value of <code>NULL</code> means that no shading lines are drawn. A zero value of <code>density</code> means no shading nor filling whereas negative values and <code>NA</code> suppress shading (and so allow color filling).</p> </td></tr> <tr valign="top"><td><code>angle</code></td> <td> <p>the slope of shading lines, given as an angle in degrees (counter-clockwise).</p> </td></tr> <tr valign="top"><td><code>col</code></td> <td> <p>the color for filling the polygon. The default, <code>NA</code>, is to leave polygons unfilled, unless <code>density</code> is specified. (For back-compatibility, <code>NULL</code> is equivalent to <code>NA</code>.) If <code>density</code> is specified with a positive value this gives the color of the shading lines.</p> </td></tr> <tr valign="top"><td><code>border</code></td> <td> <p>the color to draw the border. The default, <code>NULL</code>, means to use <code><a href="par.html">par</a>("fg")</code>. Use <code>border = NA</code> to omit borders. </p> <p>For compatibility with S, <code>border</code> can also be logical, in which case <code>FALSE</code> is equivalent to <code>NA</code> (borders omitted) and <code>TRUE</code> is equivalent to <code>NULL</code> (use the foreground colour), </p> </td></tr> <tr valign="top"><td><code>lty</code></td> <td> <p>the line type to be used, as in <code><a href="par.html">par</a></code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>graphical parameters such as <code>xpd</code>, <code>lend</code>, <code>ljoin</code> and <code>lmitre</code> can be given as arguments.</p> </td></tr> <tr valign="top"><td><code>fillOddEven</code></td> <td> <p>logical controlling the polygon shading mode: see below for details. Default <code>FALSE</code>.</p> </td></tr> </table> <h3>Details</h3> <p>The coordinates can be passed in a plotting structure (a list with <code>x</code> and <code>y</code> components), a two-column matrix, .... See <code><a href="../../grDevices/html/xy.coords.html">xy.coords</a></code>. </p> <p>It is assumed that the polygon is to be closed by joining the last point to the first point. </p> <p>The coordinates can contain missing values. The behaviour is similar to that of <code><a href="lines.html">lines</a></code>, except that instead of breaking a line into several lines, <code>NA</code> values break the polygon into several complete polygons (including closing the last point to the first point). See the examples below. </p> <p>When multiple polygons are produced, the values of <code>density</code>, <code>angle</code>, <code>col</code>, <code>border</code>, and <code>lty</code> are recycled in the usual manner. </p> <p>Shading of polygons is only implemented for linear plots: if either axis is on log scale then shading is omitted, with a warning. </p> <h3>Bugs</h3> <p>Self-intersecting polygons may be filled using either the “odd-even” or “non-zero” rule. These fill a region if the polygon border encircles it an odd or non-zero number of times, respectively. Shading lines are handled internally by <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> according to the <code>fillOddEven</code> argument, but device-based solid fills depend on the graphics device. The <code>windows</code>, <code><a href="../../grDevices/html/pdf.html">pdf</a></code> and <code><a href="../../grDevices/html/postscript.html">postscript</a></code> devices have their own <code>fillOddEven</code> argument to control this. </p> <h3>Author(s)</h3> <p>The code implementing polygon shading was donated by Kevin Buhr <a href="mailto:buhr@stat.wisc.edu">buhr@stat.wisc.edu</a>. </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="segments.html">segments</a></code> for even more flexibility, <code><a href="lines.html">lines</a></code>, <code><a href="rect.html">rect</a></code>, <code><a href="box.html">box</a></code>, <code><a href="abline.html">abline</a></code>. </p> <p><code><a href="par.html">par</a></code> for how to specify colors. </p> <h3>Examples</h3> <pre> x <- c(1:9, 8:1) y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) op <- par(mfcol = c(3, 1)) for(xpd in c(FALSE, TRUE, NA)) { plot(1:10, main = paste("xpd =", xpd)) box("figure", col = "pink", lwd = 3) polygon(x, y, xpd = xpd, col = "orange", lty = 2, lwd = 2, border = "red") } par(op) n <- 100 xx <- c(0:n, n:0) yy <- c(c(0, cumsum(stats::rnorm(n))), rev(c(0, cumsum(stats::rnorm(n))))) plot (xx, yy, type = "n", xlab = "Time", ylab = "Distance") polygon(xx, yy, col = "gray", border = "red") title("Distance Between Brownian Motions") # Multiple polygons from NA values # and recycling of col, border, and lty op <- par(mfrow = c(2, 1)) plot(c(1, 9), 1:2, type = "n") polygon(1:9, c(2,1,2,1,1,2,1,2,1), col = c("red", "blue"), border = c("green", "yellow"), lwd = 3, lty = c("dashed", "solid")) plot(c(1, 9), 1:2, type = "n") polygon(1:9, c(2,1,2,1,NA,2,1,2,1), col = c("red", "blue"), border = c("green", "yellow"), lwd = 3, lty = c("dashed", "solid")) par(op) # Line-shaded polygons plot(c(1, 9), 1:2, type = "n") polygon(1:9, c(2,1,2,1,NA,2,1,2,1), density = c(10, 20), angle = c(-45, 45)) </pre> <hr /><div style="text-align: center;">[Package <em>graphics</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>