EVOLUTION-MANAGER
Edit File: grid.function.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 a curve representing a function</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 grid.function {grid}"><tr><td>grid.function {grid}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Draw a curve representing a function</h2> <h3>Description</h3> <p>Draw a curve representing a function. </p> <h3>Usage</h3> <pre> grid.function(...) functionGrob(f, n = 101, range = "x", units = "native", name = NULL, gp=gpar(), vp = NULL) grid.abline(intercept, slope, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>f</code></td> <td> <p> A function that must take a single argument and return a list with two numeric components named <code>x</code> and <code>y</code>.</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p> The number values that will be generated as input to the function <code>f</code>.</p> </td></tr> <tr valign="top"><td><code>range</code></td> <td> <p> Either <code>"x"</code>, <code>"y"</code>, or a numeric vector. See the ‘Details’ section.</p> </td></tr> <tr valign="top"><td><code>units</code></td> <td> <p>A string indicating the units to use for the <code>x</code> and <code>y</code> values generated by the function.</p> </td></tr> <tr valign="top"><td><code>intercept</code></td> <td> <p> Numeric.</p> </td></tr> <tr valign="top"><td><code>slope</code></td> <td> <p> Numeric. </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> Arguments passed to <code>grid.function()</code></p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p> A character identifier. </p> </td></tr> <tr valign="top"><td><code>gp</code></td> <td> <p>An object of class <code>gpar</code>, typically the output from a call to the function <code>gpar</code>. This is basically a list of graphical parameter settings.</p> </td></tr> <tr valign="top"><td><code>vp</code></td> <td> <p>A Grid viewport object (or NULL).</p> </td></tr> </table> <h3>Details</h3> <p><code>n</code> values are generated and passed to the function <code>f</code> and a series of lines are drawn through the resulting <code>x</code> and <code>y</code> values. </p> <p>The generation of the <code>n</code> values depends on the value of <code>range</code>. In the default case, <code>dim</code> is <code>"x"</code>, which means that a set of <code>x</code> values are generated covering the range of the current viewport scale in the x-dimension. If <code>dim</code> is <code>"y"</code> then values are generated from the current y-scale instead. If <code>range</code> is a numeric vector, then values are generated from that range. </p> <p><code>grid.abline()</code> provides a simple front-end for a straight line parameterized by <code>intercept</code> and <code>slope</code>. </p> <h3>Value</h3> <p>A functiongrob grob. </p> <h3>Author(s)</h3> <p>Paul Murrell</p> <h3>See Also</h3> <p><a href="Grid.html">Grid</a>, <code><a href="viewport.html">viewport</a></code> </p> <h3>Examples</h3> <pre> # abline # NOTE: in ROOT viewport on screen, (0, 0) at top-left # and "native" is pixels! grid.function(function(x) list(x=x, y=0 + 1*x)) # a more "normal" viewport with default normalized "native" coords grid.newpage() pushViewport(viewport()) grid.function(function(x) list(x=x, y=0 + 1*x)) # slightly simpler grid.newpage() pushViewport(viewport()) grid.abline() # sine curve grid.newpage() pushViewport(viewport(xscale=c(0, 2*pi), yscale=c(-1, 1))) grid.function(function(x) list(x=x, y=sin(x))) # constrained sine curve grid.newpage() pushViewport(viewport(xscale=c(0, 2*pi), yscale=c(-1, 1))) grid.function(function(x) list(x=x, y=sin(x)), range=0:1) # inverse sine curve grid.newpage() pushViewport(viewport(xscale=c(-1, 1), yscale=c(0, 2*pi))) grid.function(function(y) list(x=sin(y), y=y), range="y") # parametric function grid.newpage() pushViewport(viewport(xscale=c(-1, 1), yscale=c(-1, 1))) grid.function(function(t) list(x=cos(t), y=sin(t)), range=c(0, 9*pi/5)) # physical abline grid.newpage() grid.function(function(x) list(x=x, y=0 + 1*x), units="in") </pre> <hr /><div style="text-align: center;">[Package <em>grid</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>