EVOLUTION-MANAGER
Edit File: legendGrob.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: Constructing a Legend Grob</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 legendGrob {grid}"><tr><td>legendGrob {grid}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Constructing a Legend Grob</h2> <h3>Description</h3> <p>Constructing a legend grob (in progress) </p> <h3>Usage</h3> <pre> legendGrob(labels, nrow, ncol, byrow = FALSE, do.lines = has.lty || has.lwd, lines.first = TRUE, hgap = unit(1, "lines"), vgap = unit(1, "lines"), default.units = "lines", pch, gp = gpar(), vp = NULL) grid.legend(..., draw=TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>labels</code></td> <td> <p>legend labels (expressions)</p> </td></tr> <tr valign="top"><td><code>nrow, ncol</code></td> <td> <p>integer; the number of rows or columns, respectively of the legend “layout”. <code>nrow</code> is optional and typically computed from the number of labels and <code>ncol</code>.</p> </td></tr> <tr valign="top"><td><code>byrow</code></td> <td> <p>logical indicating whether rows of the legend are filled first.</p> </td></tr> <tr valign="top"><td><code>do.lines</code></td> <td> <p>logical indicating whether legend lines are drawn.</p> </td></tr> <tr valign="top"><td><code>lines.first</code></td> <td> <p>logical indicating whether legend lines are drawn first and hence in a plain “below” legend symbols.</p> </td></tr> <tr valign="top"><td><code>hgap</code></td> <td> <p>horizontal space between the legend entries</p> </td></tr> <tr valign="top"><td><code>vgap</code></td> <td> <p>vertical space between the legend entries</p> </td></tr> <tr valign="top"><td><code>default.units</code></td> <td> <p>default units, see <code><a href="unit.html">unit</a></code>.</p> </td></tr> <tr valign="top"><td><code>pch</code></td> <td> <p>legend symbol, numeric or character, passed to <code><a href="grid.points.html">pointsGrob</a>()</code>; see also <code><a href="../../graphics/html/points.html">points</a></code> for interpretation of the numeric codes.</p> </td></tr> <tr valign="top"><td><code>gp</code></td> <td> <p>an <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object of class <code>gpar</code>, typically the output from a call to the function <code>gpar</code>, is basically a list of graphical parameter settings.</p> </td></tr> <tr valign="top"><td><code>vp</code></td> <td> <p>a Grid <code><a href="viewport.html">viewport</a></code> object (or <code>NULL</code>).</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>for <code>grid.legend()</code>: all the arguments above are passed to <code>legendGrob()</code>.</p> </td></tr> <tr valign="top"><td><code>draw</code></td> <td> <p>logical indicating whether graphics output should be produced.</p> </td></tr> </table> <h3>Value</h3> <p>Both functions create a legend <code><a href="grid.grob.html">grob</a></code> (a graphical object describing a plot legend), but only <code>grid.legend</code> draws it (only if <code>draw</code> is <code>TRUE</code>). </p> <h3>See Also</h3> <p><a href="Grid.html">Grid</a>, <code><a href="viewport.html">viewport</a></code>; <code><a href="grid.points.html">pointsGrob</a></code>, <code><a href="grid.lines.html">linesGrob</a></code>. </p> <p><code><a href="grid.plot.and.legend.html">grid.plot.and.legend</a></code> contains a simple example. </p> <h3>Examples</h3> <pre> ## Data: n <- 10 x <- stats::runif(n) ; y1 <- stats::runif(n) ; y2 <- stats::runif(n) ## Construct the grobs : plot <- gTree(children=gList(rectGrob(), pointsGrob(x, y1, pch=21, gp=gpar(col=2, fill="gray")), pointsGrob(x, y2, pch=22, gp=gpar(col=3, fill="gray")), xaxisGrob(), yaxisGrob())) legd <- legendGrob(c("Girls", "Boys", "Other"), pch=21:23, gp=gpar(col = 2:4, fill = "gray")) gg <- packGrob(packGrob(frameGrob(), plot), legd, height=unit(1,"null"), side="right") ## Now draw it on a new device page: grid.newpage() pushViewport(viewport(width=0.8, height=0.8)) grid.draw(gg) </pre> <hr /><div style="text-align: center;">[Package <em>grid</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>