\HeaderA{monthplot}{Plot a Seasonal or other Subseries from a Time Series}{monthplot}
\methaliasA{monthplot.default}{monthplot}{monthplot.default}
\methaliasA{monthplot.stl}{monthplot}{monthplot.stl}
\methaliasA{monthplot.StructTS}{monthplot}{monthplot.StructTS}
\methaliasA{monthplot.ts}{monthplot}{monthplot.ts}
\keyword{hplot}{monthplot}
\keyword{ts}{monthplot}
\begin{Description}\relax
These functions plot seasonal (or other) subseries of a time series.
For each season (or other category), a time series is plotted.
\end{Description}
\begin{Usage}
\begin{verbatim}
monthplot(x, ...)

## S3 method for class 'stl':
monthplot(x, labels = NULL, ylab = choice, choice = "seasonal",
          ...)

## S3 method for class 'StructTS':
monthplot(x, labels = NULL, ylab = choice, choice = "sea", ...)

## S3 method for class 'ts':
monthplot(x, labels = NULL, times = time(x), phase = cycle(x),
             ylab = deparse(substitute(x)), ...)

## Default S3 method:
monthplot(x, labels = 1:12,
          ylab = deparse(substitute(x)),
          times = 1:length(x),
          phase = (times - 1)%%length(labels) + 1, base = mean,
          axes = TRUE, type = c("l", "h"), box = TRUE,
          add = FALSE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] Time series or related object.
\item[\code{labels}] Labels to use for each \sQuote{season}.
\item[\code{ylab}] y label.
\item[\code{times}] Time of each observation.
\item[\code{phase}] Indicator for each \sQuote{season}.
\item[\code{base}] Function to use for reference line for subseries.
\item[\code{choice}] Which series of an \code{stl} or \code{StructTS} object?
\item[\code{...}] Arguments to be passed to the default method or
graphical parameters.
\item[\code{axes}] Should axes be drawn (ignored if \code{add=TRUE})?
\item[\code{type}] Type of plot.  The default is to join the points with
lines, and \code{"h"} is for histogram-like vertical lines.
\item[\code{box}] Should a box be drawn (ignored if \code{add=TRUE}?
\item[\code{add}] Should thus just add on an existing plot.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
These functions extract subseries from a time series and plot them
all in one frame.  The \code{\LinkA{ts}{ts}}, \code{\LinkA{stl}{stl}}, and
\code{\LinkA{StructTS}{StructTS}} methods use the internally recorded frequency and
start and finish times to set the scale and the seasons.  The default
method assumes observations come in groups of 12 (though this can be
changed).

If the \code{labels} are not given but the \code{phase} is given, then
the \code{labels} default to the unique values of the \code{phase}.  If
both are given, then the \code{phase} values are assumed to be indices
into the \code{labels} array, i.e., they should be in the range
from 1 to \code{length(labels)}.
\end{Details}
\begin{Value}
These functions are executed for their side effect of
drawing a seasonal subseries plot on the current graphical
window.
\end{Value}
\begin{Author}\relax
Duncan Murdoch
\end{Author}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{ts}{ts}}, \code{\LinkA{stl}{stl}}, \code{\LinkA{StructTS}{StructTS}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(graphics)

## The CO2 data
fit <- stl(log(co2), s.window = 20, t.window = 20)
plot(fit)
op <- par(mfrow = c(2,2))
monthplot(co2, ylab = "data", cex.axis = 0.8)
monthplot(fit, choice = "seasonal", cex.axis = 0.8)
monthplot(fit, choice = "trend", cex.axis = 0.8)
monthplot(fit, choice = "remainder", type = "h", cex.axis = 0.8)
par(op)

## The CO2 data, grouped quarterly
quarter <- (cycle(co2) - 1) %/% 3
monthplot(co2, phase = quarter)

## see also JohnsonJohnson
\end{ExampleCode}
\end{Examples}

