plothc | R Documentation |
plot.hclust
Plot an hclust
object with colored labels.
plothc(hc, labels = hc$labels, col = as.factor(labels), hang = 0.1, ...)
hc |
an |
labels |
a character vector of labels for the leaves of the tree |
col |
a vector of valid colors for |
hang |
the fraction of the plot height by which |
... |
additional arguments passed to |
Eva KF Chan, https://github.com/ekfchan/evachan.org-Rscripts, modifications by Robert Redd
hc <- hclust(dist(iris[, 1:4]))
plothc(hc)
plothc(hc, labels = iris$Species, col = as.numeric(iris$Species))
## add features below leaves
plothc(hc, col = iris$Species, xlab = '', sub = '')
set.seed(1)
mat <- matrix(rep(as.numeric(iris$Species), 3), 3)
mat[sample(length(mat), length(mat) / 2)] <- NA
mat <- sort_matrix(mat)[3:1, ]
shift <- c(0.5, 6)
rect(col(mat) - shift[1], row(mat) - shift[2], col(mat) + shift[1],
row(mat) - shift[2] + 0.5, col = mat, xpd = NA, border = 'white')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.