EVOLUTION-MANAGER
Edit File: plot.formula.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: Formula Notation for Scatterplots</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 plot.formula {graphics}"><tr><td>plot.formula {graphics}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Formula Notation for Scatterplots</h2> <h3>Description</h3> <p>Specify a scatterplot or add points, lines, or text via a formula. </p> <h3>Usage</h3> <pre> ## S3 method for class 'formula' plot(formula, data = parent.frame(), ..., subset, ylab = varnames[response], ask = dev.interactive()) ## S3 method for class 'formula' points(formula, data = parent.frame(), ..., subset) ## S3 method for class 'formula' lines(formula, data = parent.frame(), ..., subset) ## S3 method for class 'formula' text(formula, data = parent.frame(), ..., subset) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>formula</code></td> <td> <p>a <code><a href="../../stats/html/formula.html">formula</a></code>, such as <code>y ~ x</code>.</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p>a data.frame (or list) from which the variables in <code>formula</code> should be taken. A matrix is converted to a data frame.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Arguments to be passed to or from other methods. <code>horizontal = TRUE</code> is also accepted.</p> </td></tr> <tr valign="top"><td><code>subset</code></td> <td> <p>an optional vector specifying a subset of observations to be used in the fitting process.</p> </td></tr> <tr valign="top"><td><code>ylab</code></td> <td> <p>the y label of the plot(s).</p> </td></tr> <tr valign="top"><td><code>ask</code></td> <td> <p>logical, see <code><a href="par.html">par</a></code>.</p> </td></tr> </table> <h3>Details</h3> <p>For the <code>lines</code>, <code>points</code> and <code>text</code> methods the formula should be of the form <code>y ~ x</code> or <code>y ~ 1</code> with a left-hand side and a single term on the right-hand side. The <code>plot</code> method accepts other forms discussed later in this section. </p> <p>Both the terms in the formula and the <code>...</code> arguments are evaluated in <code>data</code> enclosed in <code>parent.frame()</code> if <code>data</code> is a list or a data frame. The terms of the formula and those arguments in <code>...</code> that are of the same length as <code>data</code> are subjected to the subsetting specified in <code>subset</code>. A plot against the running index can be specified as <code>plot(y ~ 1)</code>. </p> <p>If the formula in the <code>plot</code> method contains more than one term on the right-hand side, a series of plots is produced of the response against each non-response term. </p> <p>For the <code>plot</code> method the formula can be of the form <code>~ z + y + z</code>: the variables specified on the right-hand side are collected into a data frame, subsetted if specified, and displayed by <code><a href="plot.dataframe.html">plot.data.frame</a></code>. </p> <p>Missing values are not considered in these methods, and in particular cases with missing values are not removed. </p> <p>If <code>y</code> is an object (i.e., has a <code><a href="../../base/html/class.html">class</a></code> attribute) then <code>plot.formula</code> looks for a plot method for that class first. Otherwise, the class of <code>x</code> will determine the type of the plot. For factors this will be a parallel boxplot, and argument <code>horizontal = TRUE</code> can be specified (see <code><a href="boxplot.html">boxplot</a></code>). </p> <p>Note that some arguments will need to be protected from premature evaluation by enclosing them in <code><a href="../../base/html/substitute.html">quote</a></code>: currently this is done automatically for <code>main</code>, <code>sub</code> and <code>xlab</code>. For example, it is needed for the <code>panel.first</code> and <code>panel.last</code> arguments passed to <code><a href="plot.default.html">plot.default</a></code>. </p> <h3>Value</h3> <p>These functions are invoked for their side effect of drawing on the active graphics device. </p> <h3>See Also</h3> <p><code><a href="plot.default.html">plot.default</a></code>, <code><a href="points.html">points</a></code>, <code><a href="lines.html">lines</a></code>, <code><a href="plot.factor.html">plot.factor</a></code>. </p> <h3>Examples</h3> <pre> op <- par(mfrow = c(2,1)) plot(Ozone ~ Wind, data = airquality, pch = as.character(Month)) plot(Ozone ~ Wind, data = airquality, pch = as.character(Month), subset = Month != 7) par(op) ## text.formula() can be very natural: wb <- within(warpbreaks, { time <- seq_along(breaks); W.T <- wool:tension }) plot(breaks ~ time, data = wb, type = "b") text(breaks ~ time, data = wb, label = W.T, col = 1+as.integer(wool)) </pre> <hr /><div style="text-align: center;">[Package <em>graphics</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>