EVOLUTION-MANAGER
Edit File: xy.coords.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: Extracting Plotting Structures</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 xy.coords {grDevices}"><tr><td>xy.coords {grDevices}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Extracting Plotting Structures</h2> <h3>Description</h3> <p><code>xy.coords</code> is used by many functions to obtain x and y coordinates for plotting. The use of this common mechanism across all relevant <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> functions produces a measure of consistency. </p> <h3>Usage</h3> <pre> xy.coords(x, y = NULL, xlab = NULL, ylab = NULL, log = NULL, recycle = FALSE, setLab = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y</code></td> <td> <p>the x and y coordinates of a set of points. Alternatively, a single argument <code>x</code> can be provided.</p> </td></tr> <tr valign="top"><td><code>xlab, ylab</code></td> <td> <p>names for the x and y variables to be extracted.</p> </td></tr> <tr valign="top"><td><code>log</code></td> <td> <p>character, <code>"x"</code>, <code>"y"</code> or both, as for <code><a href="../../graphics/html/plot.html">plot</a></code>. Sets negative values to <code><a href="../../base/html/NA.html">NA</a></code> and gives a warning.</p> </td></tr> <tr valign="top"><td><code>recycle</code></td> <td> <p>logical; if <code>TRUE</code>, recycle (<code><a href="../../base/html/rep.html">rep</a></code>) the shorter of <code>x</code> or <code>y</code> if their lengths differ.</p> </td></tr> <tr valign="top"><td><code>setLab</code></td> <td> <p>logical indicating if the resulting <code>xlab</code> and <code>ylab</code> should be constructed from the “kind” of <code>(x,y)</code>; otherwise, the arguments <code>xlab</code> and <code>ylab</code> are used.</p> </td></tr> </table> <h3>Details</h3> <p>An attempt is made to interpret the arguments <code>x</code> and <code>y</code> in a way suitable for bivariate plotting (or other bivariate procedures). </p> <p>If <code>y</code> is <code>NULL</code> and <code>x</code> is a </p> <dl> <dt>formula:</dt><dd><p>of the form <code>yvar ~ xvar</code>. <code>xvar</code> and <code>yvar</code> are used as x and y variables.</p> </dd> <dt>list:</dt><dd><p>containing components <code>x</code> and <code>y</code>, these are used to define plotting coordinates.</p> </dd> <dt>time series:</dt><dd><p>the x values are taken to be <code><a href="../../stats/html/time.html">time</a>(x)</code> and the y values to be the time series.</p> </dd> <dt>matrix or <code><a href="../../base/html/data.frame.html">data.frame</a></code> with two or more columns:</dt><dd><p>the first is assumed to contain the x values and the second the y values. <em>Note</em> that is also true if <code>x</code> has columns named <code>"x"</code> and <code>"y"</code>; these names will be irrelevant here.</p> </dd> </dl> <p>In any other case, the <code>x</code> argument is coerced to a vector and returned as <b>y</b> component where the resulting <code>x</code> is just the index vector <code>1:n</code>. In this case, the resulting <code>xlab</code> component is set to <code>"Index"</code> (if <code>setLab</code> is true as by default). </p> <p>If <code>x</code> (after transformation as above) inherits from class <code>"POSIXt"</code> it is coerced to class <code>"POSIXct"</code>. </p> <h3>Value</h3> <p>A list with the components </p> <table summary="R valueblock"> <tr valign="top"><td><code>x</code></td> <td> <p>numeric (i.e., <code>"double"</code>) vector of abscissa values.</p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>numeric vector of the same length as <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>xlab</code></td> <td> <p><code>character(1)</code> or <code>NULL</code>, the ‘label’ of <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>ylab</code></td> <td> <p><code>character(1)</code> or <code>NULL</code>, the ‘label’ of <code>y</code>.</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="../../graphics/html/plot.default.html">plot.default</a></code>, <code><a href="../../graphics/html/lines.html">lines</a></code>, <code><a href="../../graphics/html/points.html">points</a></code> and <code><a href="../../stats/html/lowess.html">lowess</a></code> are examples of functions which use this mechanism. </p> <h3>Examples</h3> <pre> ff <- stats::fft(1:9) xy.coords(ff) xy.coords(ff, xlab = "fft") # labels "Re(fft)", "Im(fft)" with(cars, xy.coords(dist ~ speed, NULL)$xlab ) # = "speed" xy.coords(1:3, 1:2, recycle = TRUE) # otherwise error "lengths differ" xy.coords(-2:10, log = "y") ##> xlab: "Index" \\ warning: 3 y values <= 0 omitted .. </pre> <hr /><div style="text-align: center;">[Package <em>grDevices</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>