\HeaderA{plot.rpart}{Plot an Rpart Object}{plot.rpart}
\keyword{tree}{plot.rpart}
\begin{Description}\relax
Plots an rpart object on the current graphics device.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'rpart':
plot(x, uniform=FALSE, branch=1, compress=FALSE, nspace,
     margin=0, minbranch=.3, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a fitted object of class \code{rpart}, containing a classification,
regression, or rate tree.

\item[\code{uniform}] if \code{TRUE}, uniform vertical spacing of the nodes is used; this may be
less cluttered when fitting a large plot onto a page.
The default is to use a non-uniform spacing proportional to the 
error in the fit.

\item[\code{branch}] controls the shape of the branches from parent to child node.
Any number from 0 to 1 is allowed.  A value of 1 gives square
shouldered branches, a value of 0 give V shaped branches, 
with other values being intermediate.

\item[\code{compress}] if \code{FALSE}, the leaf nodes will be at the horzontal plot coordinates of
\code{1:nleaves}.  
If \code{TRUE}, the routine attempts a more compact arrangement of
the tree.
The compaction algorithm assumes \code{uniform=TRUE}; surprisingly, the result
is usually an improvement even when that is not the case.

\item[\code{nspace}] the amount of extra space between a node with children and
a leaf, as compared to the minimal space between leaves.  
Applies to compressed trees only.  The default is the value of
\code{branch}.

\item[\code{margin}] an extra percentage of white space to leave around the borders of the tree.
(Long labels sometimes get cut off by the default computation).

\item[\code{minbranch}] set the minimum length for a branch to \code{minbranch} times the average
branch length.  This parameter is ignored if \code{uniform=TRUE}.
Sometimes a split will give very little improvement, or even (in
the classification case) no improvement at all.  
A tree with branch lengths strictly proportional to improvement
leaves no room to squeeze in node labels.

\item[\code{...}] arguments to be passed to or from other methods.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function is a method for the generic function \code{plot}, for objects
of class \code{rpart}.
The y-coordinate of the top node of the tree will always be 1.
\end{Details}
\begin{Value}
the coordinates of the nodes are returned as a list, with
components \code{x} and \code{y}.
\end{Value}
\begin{Section}{Side Effects}
an unlabeled plot is produced on the current graphics device.
\end{Section}
\begin{SeeAlso}\relax
\code{\LinkA{rpart}{rpart}}, \code{\LinkA{text.rpart}{text.rpart}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
fit <- rpart(Price ~ Mileage + Type + Country, cu.summary)
plot(fit, compress=TRUE)
text(fit, use.n=TRUE)
\end{ExampleCode}
\end{Examples}

