\HeaderA{plot.design}{Plot Univariate Effects of a `Design' or Model}{plot.design}
\keyword{hplot}{plot.design}
\begin{Description}\relax
Plot univariate effects of one ore more \code{\LinkA{factor}{factor}}s,
typically for a designed experiment as analyzed by \code{\LinkA{aov}{aov}()}.
Further, in S this a method of the \code{\LinkA{plot}{plot}} generic function
for \code{design} objects.
\end{Description}
\begin{Usage}
\begin{verbatim}
plot.design(x, y = NULL, fun = mean, data = NULL, ...,
            ylim = NULL, xlab = "Factors", ylab = NULL,
            main = NULL, ask = NULL, xaxt = par("xaxt"),
            axes = TRUE, xtick = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] either a data frame containing the design factors and
optionally the response, or a \code{\LinkA{formula}{formula}} or
\code{\LinkA{terms}{terms}} object.
\item[\code{y}] the response, if not given in x.
\item[\code{fun}] a function (or name of one) to be applied to each
subset.  It must return one number for a numeric (vector) input.
\item[\code{data}] data frame containing the variables referenced by \code{x}
when that is formula like.
\item[\code{...}] graphical arguments such as \code{col}, see \code{\LinkA{par}{par}}.
\item[\code{ylim}] range of y values, as in \code{\LinkA{plot.default}{plot.default}}.
\item[\code{xlab}] x axis label, see \code{\LinkA{title}{title}}.
\item[\code{ylab}] y axis label with a \dQuote{smart} default.
\item[\code{main}] main title, see \code{\LinkA{title}{title}}.
\item[\code{ask}] logical indicating if the user should be asked before a new
page is started -- in the case of multiple y's.
\item[\code{xaxt}] character giving the type of x axis.
\item[\code{axes}] logical indicating if axes should be drawn.
\item[\code{xtick}] logical indicating if \dQuote{ticks} (one per factor) should
be drawn on the x axis.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The supplied function will be called once for each level of each
factor in the design and the plot will show these summary values.  The
levels of a particular factor are shown along a vertical line, and the
overall value of \code{fun()} for the response is drawn as a
horizontal line.

This is a new \R{} implementation which will not be completely
compatible to the earlier S implementations.  This is not a bug but
might still change.
\end{Details}
\begin{Note}\relax
A big effort was taken to make this closely compatible to the S
version.  However, \code{col} (and \code{fg}) specification has
different effects.
\end{Note}
\begin{Author}\relax
Roberto Frisullo and Martin Maechler
\end{Author}
\begin{References}\relax
Chambers, J. M. and Hastie, T. J. eds (1992)
\emph{Statistical Models in S}.
Chapman \& Hall, London, \bold{the} \emph{white book}, pp. 546--7 (and 163--4).

Freeny, A. E. and Landwehr, J. M. (1990)
Displays for data from large designed experiments;
Computer Science and Statistics: Proc.\ 22nd Symp\. Interface, 117--126,
Springer Verlag.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{interaction.plot}{interaction.plot}} for a \dQuote{standard graphic}
of designed experiments.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
plot.design(warpbreaks)# automatic for data frame with one numeric var.

Form <- breaks ~ wool + tension
summary(fm1 <- aov(Form, data = warpbreaks))
plot.design(       Form, data = warpbreaks, col = 2)# same as above

## More than one y :
utils::str(esoph)
plot.design(esoph) ## two plots; if interactive you are "ask"ed

## or rather, compare mean and median:
op <- par(mfcol = 1:2)
plot.design(ncases/ncontrols ~ ., data = esoph, ylim = c(0, 0.8))
plot.design(ncases/ncontrols ~ ., data = esoph, ylim = c(0, 0.8),
            fun = median)
par(op)
\end{ExampleCode}
\end{Examples}

