EVOLUTION-MANAGER
Edit File: gpar.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: Handling Grid Graphical Parameters</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 gpar {grid}"><tr><td>gpar {grid}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Handling Grid Graphical Parameters</h2> <h3>Description</h3> <p><code>gpar()</code> should be used to create a set of graphical parameter settings. It returns an object of class <code>"gpar"</code>. This is basically a list of name-value pairs. </p> <p><code>get.gpar()</code> can be used to query the current graphical parameter settings. </p> <h3>Usage</h3> <pre> gpar(...) get.gpar(names = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p> Any number of named arguments. </p> </td></tr> <tr valign="top"><td><code>names</code></td> <td> <p>A character vector of valid graphical parameter names.</p> </td></tr> </table> <h3>Details</h3> <p>All grid viewports and (predefined) graphical objects have a slot called <code>gp</code>, which contains a <code>"gpar"</code> object. When a viewport is pushed onto the viewport stack and when a graphical object is drawn, the settings in the <code>"gpar"</code> object are enforced. In this way, the graphical output is modified by the <code>gp</code> settings until the graphical object has finished drawing, or until the viewport is popped off the viewport stack, or until some other viewport or graphical object is pushed or begins drawing. </p> <p>The default parameter settings are defined by the ROOT viewport, which takes its settings from the graphics device. These defaults may differ between devices (e.g., the default <code>fill</code> setting is different for a PNG device compared to a PDF device). </p> <p>Valid parameter names are: </p> <table summary="Rd table"> <tr> <td style="text-align: left;"> col </td><td style="text-align: left;"> Colour for lines and borders. </td> </tr> <tr> <td style="text-align: left;"> fill </td><td style="text-align: left;"> Colour for filling rectangles, polygons, ... </td> </tr> <tr> <td style="text-align: left;"> alpha </td><td style="text-align: left;"> Alpha channel for transparency </td> </tr> <tr> <td style="text-align: left;"> lty </td><td style="text-align: left;"> Line type </td> </tr> <tr> <td style="text-align: left;"> lwd </td><td style="text-align: left;"> Line width </td> </tr> <tr> <td style="text-align: left;"> lex </td><td style="text-align: left;"> Multiplier applied to line width </td> </tr> <tr> <td style="text-align: left;"> lineend </td><td style="text-align: left;"> Line end style (round, butt, square) </td> </tr> <tr> <td style="text-align: left;"> linejoin </td><td style="text-align: left;"> Line join style (round, mitre, bevel) </td> </tr> <tr> <td style="text-align: left;"> linemitre </td><td style="text-align: left;"> Line mitre limit (number greater than 1) </td> </tr> <tr> <td style="text-align: left;"> fontsize </td><td style="text-align: left;"> The size of text (in points) </td> </tr> <tr> <td style="text-align: left;"> cex </td><td style="text-align: left;"> Multiplier applied to fontsize </td> </tr> <tr> <td style="text-align: left;"> fontfamily </td><td style="text-align: left;"> The font family </td> </tr> <tr> <td style="text-align: left;"> fontface </td><td style="text-align: left;"> The font face (bold, italic, ...) </td> </tr> <tr> <td style="text-align: left;"> lineheight </td><td style="text-align: left;"> The height of a line as a multiple of the size of text </td> </tr> <tr> <td style="text-align: left;"> font </td><td style="text-align: left;"> Font face (alias for fontface; for backward compatibility) </td> </tr> <tr> <td style="text-align: left;"> </td> </tr> </table> <p>For more details of many of these, see the help for the corresponding graphical parameter <code><a href="../../graphics/html/par.html">par</a></code> in base graphics. (This may have a slightly different name, e.g. <code>lend</code>, <code>ljoin</code>, <code>lmitre</code>, <code>family</code>.) </p> <p>Colours can be specified in one of the forms returned by <code><a href="../../grDevices/html/rgb.html">rgb</a></code>, as a name (see <code><a href="../../grDevices/html/colors.html">colors</a></code>) or as a non-negative integer index into the current <a href="../../grDevices/html/palette.html">palette</a> (with zero being taken as transparent). (Negative integer values are now an error.) </p> <p>The <code>alpha</code> setting is combined with the alpha channel for individual colours by multiplying (with both alpha settings normalised to the range 0 to 1). </p> <p>The size of text is <code>fontsize</code>*<code>cex</code>. The size of a line is <code>fontsize</code>*<code>cex</code>*<code>lineheight</code>. </p> <p>The <code>cex</code> setting is cumulative; if a viewport is pushed with a <code>cex</code> of 0.5 then another viewport is pushed with a <code>cex</code> of 0.5, the effective <code>cex</code> is 0.25. </p> <p>The <code>alpha</code> and <code>lex</code> settings are also cumulative. </p> <p>Changes to the <code>fontfamily</code> may be ignored by some devices, but is supported by PostScript, PDF, X11, Windows, and Quartz. The <code>fontfamily</code> may be used to specify one of the Hershey Font families (e.g., <code>HersheySerif</code>) and this specification will be honoured on all devices. </p> <p>The specification of <code>fontface</code> can be an integer or a string. If an integer, then it follows the R base graphics standard: 1 = plain, 2 = bold, 3 = italic, 4 = bold italic. If a string, then valid values are: <code>"plain"</code>, <code>"bold"</code>, <code>"italic"</code>, <code>"oblique"</code>, and <code>"bold.italic"</code>. For the special case of the HersheySerif font family, <code>"cyrillic"</code>, <code>"cyrillic.oblique"</code>, and <code>"EUC"</code> are also available. </p> <p>All parameter values can be vectors of multiple values. (This will not always make sense – for example, viewports will only take notice of the first parameter value.) </p> <p><code>get.gpar()</code> returns all current graphical parameter settings. </p> <h3>Value</h3> <p>An object of class <code>"gpar"</code>. </p> <h3>Author(s)</h3> <p>Paul Murrell</p> <h3>See Also</h3> <p><code><a href="../../grDevices/html/Hershey.html">Hershey</a></code>. </p> <h3>Examples</h3> <pre> gp <- get.gpar() utils::str(gp) ## These *do* nothing but produce a "gpar" object: gpar(col = "red") gpar(col = "blue", lty = "solid", lwd = 3, fontsize = 16) get.gpar(c("col", "lty")) grid.newpage() vp <- viewport(w = .8, h = .8, gp = gpar(col="blue")) grid.draw(gTree(children=gList(rectGrob(gp = gpar(col="red")), textGrob(paste("The rect is its own colour (red)", "but this text is the colour", "set by the gTree (green)", sep = "\n"))), gp = gpar(col="green"), vp = vp)) grid.text("This text is the colour set by the viewport (blue)", y = 1, just = c("center", "bottom"), gp = gpar(fontsize=20), vp = vp) grid.newpage() ## example with multiple values for a parameter pushViewport(viewport()) grid.points(1:10/11, 1:10/11, gp = gpar(col=1:10)) popViewport() </pre> <hr /><div style="text-align: center;">[Package <em>grid</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>