Plot Trees From Hierarchical Clustering

DESCRIPTION:
Creates a plot of a clustering tree given a structure produced by hclust.

USAGE:
plclust(tree, hang = .1, unit = F, level = F, hmin = 0,
        square = T, labels = <<see below>>, plot = T)

REQUIRED ARGUMENTS:
tree:
a hierarchical clustering tree, of the form returned by function hclust.

OPTIONAL ARGUMENTS:
hang:
the fraction of the height of the plot that each individual node will hang below the cluster that it joins. A value of -1 will cause all individuals to start at y-value 0.
unit:
logical flag: if TRUE, the heights of the merges will be ignored and instead merge i will occur at height i. Useful for spreading out the tree to see the sequence of merges.
level:
logical flag: if TRUE, the plotted tree will be "leveled", where merges in different subtrees are arbitrarily assigned the same height in order to compress the vertical scale. This is useful with unit=TRUE.
hmin:
minimum height at which merges will take place. This can be used to get rid of irrelevant detail at low levels.
square:
logical flag: if TRUE, the tree is plotted with "U" shaped branches, if FALSE, it has "V" shaped branches.
labels:
vector of character strings giving the labels for the leaves of the tree. If omitted, leaves will be labeled by number. To omit labels entirely, use labels=FALSE.
plot:
logical flag: If TRUE, plotting takes place. If FALSE, no plotting is done but a value is returned.

Graphical parameters may also be supplied as arguments to this function (see par). In addition, the high-level graphics arguments described under par and the arguments to title may be supplied to this function.


VALUE:
if plot is FALSE, a list containing the coordinates of the leaves of the tree and the interior nodes of the tree:
x,y:
x and y coordinates of the leaves of the tree, i.e., x[i],y[i] gives the coordinates of the leaf corresponding to the ith individual.
xn,yn:
x and y coordinates of the interior nodes of the tree, i.e., xn[i],yn[i] gives the coordinates of the node representing the ith merge.

SIDE EFFECTS:
if plot is TRUE, a clustering tree is plotted on the current graphics device.

DETAILS:
Creates a plot of a clustering tree given a structure by the function hclust. Can produce a plot of a clustering tree on the current graphics device, or a list containing the coordinates of the leaves of the tree and the interior nodes of the tree.

SEE ALSO:
cutree , dist , hclust , identify , labclust , par , subtree , title .

EXAMPLES:
# create sample object using built-in data
distances <- dist(votes.repub))
plclust(hclust(distances))

# another example x <- hclust(dist(longley.y)) plclust(x, label = FALSE) # plot without labels xy <- plclust(tree, plot = FALSE) # no plot, save structure # allow user to point at leaf and have it identified identify(xy)

sums <- apply(author.count,1,sum) adjusted <- sweep(author.count,1,sums,"/") par(mar=c(18,4,4,1)) plclust(hclust(dist(adjusted)),label=dimnames(author.count)[[1]]) title("Clustering of Books Based on Letter Frequency")