# Function hcoplot() # Reorder and plot dendrogram with colors for groups and legend # # Usage: # hcoplot(tree = hclust.object, diss = dissimilarity.matrix, k = nb.clusters, # title = paste("Reordered dendrogram from",deparse(tree$call),sep="\n")) # # License: GPL-2 # Author: Francois Gillet, 23 August 2012 "hcoplot" <- function(tree, diss, k, title=paste("Reordered dendrogram from", deparse(tree$call), sep="\n")) { require(gclus) gr <- cutree(tree, k=k) tor <- reorder.hclust(tree, diss) plot(tor, hang=-1, xlab=paste(length(gr),"sites"), sub=paste(k,"clusters"), main=title) so <- gr[tor$order] gro <- numeric(k) for (i in 1:k) { gro[i] <- so[1] if (i