[R] Dendrogram plotting options?

Martin Maechler maechler at stat.math.ethz.ch
Mon Jul 19 09:32:50 CEST 2004

    Mark> Hi, I was wondering if there is more flexibility in the output of 
    Mark> dendrograms when plotting a hclust object. 

This is becoming a real FAQ.
{Have you tried to find the answer in the searchable "R-help" archives?}

    Mark> dendrograms when plotting a hclust object. I can't seem to find 
    Mark> information on how to change the default output of a "hanging" style 
    Mark> tree with the axis on the right to a left-to-right plot with and axis 
    Mark> on the bottom. Example  code follows:

    Mark> library(vegan) #loads the "vegan" module that compuptes ANOSIM
    Mark> library(cluster)
    Mark> community <- read.csv("ANOSIMmites.csv", header=TRUE) #reads the data 

we don't have that file. So why don't you rather use a
*reproducible* example as the posting guide (bottom line of
every R-help message) tells you to ?

    Mark>  <<... hence irrelevant ...>

    Mark> clust <- hclust(community.dist, method = "complete", members=NULL)

    Mark> plot(clust, labels = sample, hang = 0.05, axes = TRUE, frame.plot = 
    Mark>      FALSE, ann = F, main = "Dendrogram of sample similarity", 
    Mark>      sub = "based on associated soil mite species", 
    Mark>      xlab = NULL, ylab = "Height")

"The" answer in principle is

    d.cl <- as.dendrogram(clust, hang = 0.05)## <-- 'hang' must be here
    plot(d.cl, ..................., horiz = TRUE)

and the "R-devel" version allows even quite a few more options to
dendrogram plotting than "current R".

Martin Maechler, Seminar fuer Statistik, ETH Zurich

More information about the R-help mailing list