[R] Justification of dendrogram labels
Martin Maechler
maechler at stat.math.ethz.ch
Fri Jan 27 09:07:46 CET 2006
>>>>> "DMackay" == Duncan Mackay <duncan.mackay at flinders.edu.au>
>>>>> on Fri, 27 Jan 2006 11:46:11 +1030 writes:
DMackay> Hi all,
DMackay> Can someone tell me how to justify (right or left) the labels on the
DMackay> branches of a dendrogram tree? I have produced a dendrogram via agnes and
DMackay> plotted it with pltree. The dendrogram terminal branch labels seem to be
DMackay> centre-justified by default and I was hoping to change this to left
DMackay> justification. Thanks,
No, you can't when using pltree(). But you can by other means:
I just now realize how scarce help(pltree)
and help(pltree.twins) are on this --- and I will improve these help pages.
pltree() leads to the following call sequence:
pltree() -> cluster:::pltree.twins -> stats:::plot.hclust()
and the plot.hclust() function, the S3 method for plot()ting "hclust"
objects, delves into fast but rather inflexible C code.
This has been one of the reasons why the "dendrogram" (S3) class
had been introduced. These are more flexible and have a more
flexible plot method.
--> help(plot.dendrogram)
and the "graphics show" you get from example(as.dendrogram).
(and then study the 'Examples:' section of the help page
more carefully).
To coerce agnes() results to "dendrogram", you need something like
aa <- agnes(..........)
dd <- as.dendrogram(as.hclust(aa))
## and now
plot(dd)
## or
plot(*, ..........)
--
Martin Maechler, ETH Zurich
More information about the R-help
mailing list