EVOLUTION-MANAGER
Edit File: rect.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: Draw One or More Rectangles</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 rect {graphics}"><tr><td>rect {graphics}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Draw One or More Rectangles</h2> <h3>Description</h3> <p><code>rect</code> draws a rectangle (or sequence of rectangles) with the given coordinates, fill and border colors. </p> <h3>Usage</h3> <pre> rect(xleft, ybottom, xright, ytop, density = NULL, angle = 45, col = NA, border = NULL, lty = par("lty"), lwd = par("lwd"), ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>xleft</code></td> <td> <p>a vector (or scalar) of left x positions.</p> </td></tr> <tr valign="top"><td><code>ybottom</code></td> <td> <p>a vector (or scalar) of bottom y positions.</p> </td></tr> <tr valign="top"><td><code>xright</code></td> <td> <p>a vector (or scalar) of right x positions.</p> </td></tr> <tr valign="top"><td><code>ytop</code></td> <td> <p>a vector (or scalar) of top y positions.</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 lines 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>angle (in degrees) of the shading lines.</p> </td></tr> <tr valign="top"><td><code>col</code></td> <td> <p>color(s) to fill or shade the rectangle(s) with. The default <code>NA</code> (or also <code>NULL</code>) means do not fill, i.e., draw transparent rectangles, unless <code>density</code> is specified.</p> </td></tr> <tr valign="top"><td><code>border</code></td> <td> <p>color for rectangle border(s). The default means <code>par("fg")</code>. Use <code>border = NA</code> to omit borders. If there are shading lines, <code>border = TRUE</code> means use the same colour for the border as for the shading lines.</p> </td></tr> <tr valign="top"><td><code>lty</code></td> <td> <p>line type for borders and shading; defaults to <code>"solid"</code>.</p> </td></tr> <tr valign="top"><td><code>lwd</code></td> <td> <p>line width for borders and shading. Note that the use of <code>lwd = 0</code> (as in the examples) is device-dependent.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p><a href="par.html">graphical parameters</a> such as <code>xpd</code>, <code>lend</code>, <code>ljoin</code> and <code>lmitre</code> can be given as arguments.</p> </td></tr> </table> <h3>Details</h3> <p>The positions supplied, i.e., <code>xleft, ...</code>, are relative to the current plotting region. If the x-axis goes from 100 to 200 then <code>xleft</code> must be larger than 100 and <code>xright</code> must be less than 200. The position vectors will be recycled to the length of the longest. </p> <p>It is a graphics primitive used in <code><a href="hist.html">hist</a></code>, <code><a href="barplot.html">barplot</a></code>, <code><a href="legend.html">legend</a></code>, etc. </p> <h3>See Also</h3> <p><code><a href="box.html">box</a></code> for the standard box around the plot; <code><a href="polygon.html">polygon</a></code> and <code><a href="segments.html">segments</a></code> for flexible line drawing. </p> <p><code><a href="par.html">par</a></code> for how to specify colors. </p> <h3>Examples</h3> <pre> require(grDevices) ## set up the plot region: op <- par(bg = "thistle") plot(c(100, 250), c(300, 450), type = "n", xlab = "", ylab = "", main = "2 x 11 rectangles; 'rect(100+i,300+i, 150+i,380+i)'") i <- 4*(0:10) ## draw rectangles with bottom left (100, 300)+i ## and top right (150, 380)+i rect(100+i, 300+i, 150+i, 380+i, col = rainbow(11, start = 0.7, end = 0.1)) rect(240-i, 320+i, 250-i, 410+i, col = heat.colors(11), lwd = i/5) ## Background alternating ( transparent / "bg" ) : j <- 10*(0:5) rect(125+j, 360+j, 141+j, 405+j/2, col = c(NA,0), border = "gold", lwd = 2) rect(125+j, 296+j/2, 141+j, 331+j/5, col = c(NA,"midnightblue")) mtext("+ 2 x 6 rect(*, col = c(NA,0)) and col = c(NA,\"m..blue\")") ## an example showing colouring and shading plot(c(100, 200), c(300, 450), type= "n", xlab = "", ylab = "") rect(100, 300, 125, 350) # transparent rect(100, 400, 125, 450, col = "green", border = "blue") # coloured rect(115, 375, 150, 425, col = par("bg"), border = "transparent") rect(150, 300, 175, 350, density = 10, border = "red") rect(150, 400, 175, 450, density = 30, col = "blue", angle = -30, border = "transparent") legend(180, 450, legend = 1:4, fill = c(NA, "green", par("fg"), "blue"), density = c(NA, NA, 10, 30), angle = c(NA, NA, 30, -30)) par(op) </pre> <hr /><div style="text-align: center;">[Package <em>graphics</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>