# plot.formula

##### Formula Notation for Scatterplots

Specify a scatterplot or add points, lines, or text via a formula.

##### Usage

```
# S3 method for formula
plot(formula, data = parent.frame(), …, subset,
ylab = varnames[response], ask = dev.interactive())
```# S3 method for formula
points(formula, data = parent.frame(), …, subset)

# S3 method for formula
lines(formula, data = parent.frame(), …, subset)

# S3 method for formula
text(formula, data = parent.frame(), …, subset)

##### Arguments

- formula
a

`formula`

, such as`y ~ x`

.- data
a data.frame (or list) from which the variables in

`formula`

should be taken. A matrix is converted to a data frame.- …
Arguments to be passed to or from other methods.

`horizontal = TRUE`

is also accepted.- subset
an optional vector specifying a subset of observations to be used in the fitting process.

- ylab
the y label of the plot(s).

- ask
logical, see

`par`

.

##### Details

For the `lines`

, `points`

and `text`

methods the formula
should be of the form `y ~ x`

or `y ~ 1`

with a left-hand
side and a single term on the right-hand side. The `plot`

method
accepts other forms discussed later in this section.

Both the terms in the formula and the `…`

arguments are
evaluated in `data`

enclosed in `parent.frame()`

if
`data`

is a list or a data frame. The terms of the formula and
those arguments in `…`

that are of the same length as
`data`

are subjected to the subsetting specified in
`subset`

. A plot against the running index can be specified as
`plot(y ~ 1)`

.

If the formula in the `plot`

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.

For the `plot`

method the formula can be of the form
`~ z + y + z`

: the variables specified on the right-hand side are
collected into a data frame, subsetted if specified, and displayed by
`plot.data.frame`

.

Missing values are not considered in these methods, and in particular cases with missing values are not removed.

If `y`

is an object (i.e., has a `class`

attribute)
then `plot.formula`

looks for a plot method for that class first.
Otherwise, the class of `x`

will determine the type of the plot.
For factors this will be a parallel boxplot, and argument
`horizontal = TRUE`

can be specified (see `boxplot`

).

Note that some arguments will need to be protected from premature
evaluation by enclosing them in `quote`

: currently this is
done automatically for `main`

, `sub`

and `xlab`

. For
example, it is needed for the `panel.first`

and `panel.last`

arguments passed to `plot.default`

.

##### Value

These functions are invoked for their side effect of drawing on the active graphics device.

##### See Also

##### Examples

`library(graphics)`

```
# NOT RUN {
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))
# }
```

*Documentation reproduced from package graphics, version 3.5.0, License: Part of R 3.5.0*