\HeaderA{plot.agnes}{Plots of an Agglomerative Hierarchical Clustering}{plot.agnes}
\keyword{cluster}{plot.agnes}
\keyword{hplot}{plot.agnes}
\begin{Description}\relax
Creates plots for visualizing an \code{agnes} object.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'agnes':
plot(x, ask = FALSE, which.plots = NULL, main = NULL,
           sub = paste("Agglomerative Coefficient = ",round(x$ac, digits = 2)),
           adj = 0, nmax.lab = 35, max.strlen = 5, xax.pretty = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an object of class \code{"agnes"}, typically created by
\code{\LinkA{agnes}{agnes}(.)}.
\item[\code{ask}] logical; if true and \code{which.plots} is \code{NULL},
\code{plot.agnes} operates in interactive mode, via \code{\LinkA{menu}{menu}}.
\item[\code{which.plots}] integer vector or NULL (default), the latter
producing both plots.  Otherwise, \code{which.plots}
must contain integers of \code{1} for a \emph{banner} plot or \code{2} for a
dendrogram or ``clustering tree''.
\item[\code{main, sub}] main and sub title for the plot, with convenient
defaults.  See documentation for these arguments in \code{\LinkA{plot.default}{plot.default}}.
\item[\code{adj}] for label adjustment in \code{\LinkA{bannerplot}{bannerplot}()}.
\item[\code{nmax.lab}] integer indicating the number of labels which is
considered too large for single-name labelling the banner plot.
\item[\code{max.strlen}] positive integer giving the length to which
strings are truncated in banner plot labeling.
\item[\code{xax.pretty}] logical or integer indicating if
\code{\LinkA{pretty}{pretty}(*, n = xax.pretty)} should be used for the x axis.
\code{xax.pretty = FALSE} is for back compatibility.
\item[\code{...}] graphical parameters (see \code{\LinkA{par}{par}}) may also
be supplied and are passed to \code{\LinkA{bannerplot}{bannerplot}()} or
\code{\LinkA{pltree}{pltree}()}, respectively.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
When \code{ask = TRUE}, rather than producing each plot sequentially,
\code{plot.agnes} displays a menu listing all the plots that can be produced.
If the menu is not desired but a pause between plots is still wanted
one must set \code{par(ask= TRUE)} before invoking the plot command.

The banner displays the hierarchy of clusters, and is equivalent to a tree.
See Rousseeuw (1986) or chapter 5 of Kaufman and Rousseeuw (1990).
The banner plots distances at which observations and clusters are merged.
The observations are listed in the order found by the \code{agnes} algorithm,
and the numbers in the \code{height} vector are represented as bars
between the observations.

The leaves of the clustering tree are the original observations.  Two
branches come together at the distance between the two clusters being merged.

For more customization of the plots, rather call
\code{\LinkA{bannerplot}{bannerplot}} and \code{\LinkA{pltree}{pltree}} directly with
corresponding arguments, e.g., \code{xlab} or \code{ylab}.
\end{Details}
\begin{Section}{Side Effects}
Appropriate plots are produced on the current graphics device. This can
be one or both of the following choices:
\\ Banner
\\ Clustering tree
\end{Section}
\begin{Note}\relax
In the banner plot, observation labels are only printed when the
number of observations is limited less than \code{nmax.lab} (35, by
default), for readability.  Moreover, observation labels are truncated
to maximally \code{max.strlen} (5) characters.
\end{Note}
\begin{References}\relax
Kaufman, L. and Rousseeuw, P.J. (1990)
\emph{Finding Groups in Data: An Introduction to Cluster Analysis}.
Wiley, New York.

Rousseeuw, P.J. (1986). A visual display for hierarchical classification,
in \emph{Data Analysis and Informatics 4}; edited by E. Diday,
Y. Escoufier, L. Lebart, J. Pages, Y. Schektman, and R. Tomassone.
North-Holland, Amsterdam, 743--748.

Struyf, A., Hubert, M. and Rousseeuw, P.J. (1997)
Integrating Robust Clustering Techniques in S-PLUS,
\emph{Computational Statistics and Data Analysis}, \bold{26}, 17-37.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{agnes}{agnes}} and \code{\LinkA{agnes.object}{agnes.object}};
\code{\LinkA{bannerplot}{bannerplot}}, \code{\LinkA{pltree}{pltree}}, and \code{\LinkA{par}{par}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Can also pass `labels' to pltree() and bannerplot():
data(iris)
cS <- as.character(Sp <- iris$Species)
cS[Sp == "setosa"] <- "S"
cS[Sp == "versicolor"] <- "V"
cS[Sp == "virginica"] <- "g"
ai <- agnes(iris[, 1:4])
plot(ai, labels = cS, nmax = 150)# bannerplot labels are mess
\end{ExampleCode}
\end{Examples}

