Color dend's labels according to sub-clusters
This function is for dendrogram and hclust objects. This function colors tree's labels.
The groups will be defined by a call to cutree
using the k or h parameters.
If col is a color vector with a different length than the number of clusters (k) - then a recycled color vector will be used.
color_labels( dend, k = NULL, h = NULL, labels, col, warn = dendextend_options("warn"), ... )
dend |
A |
k |
number of groups (passed to |
h |
height at which to cut tree (passed to |
labels |
character vecotor. If not missing, it overrides k and h, and simply colors these labels in the tree based on "col" parameter. |
col |
Function or vector of Colors. By default it tries to use
rainbow_hcl from the |
warn |
logical (default from dendextend_options("warn") is FALSE). Set if warning are to be issued, it is safer to keep this at TRUE, but for keeping the noise down, the default is FALSE. (in case h/k/labels are not supplied, or if col is too short) |
... |
ignored. |
a tree object of class dendrogram.
This function is in the style of color_branches
, and
based on labels_colors
.
## Not run: hc <- hclust(dist(USArrests), "ave") dend <- as.dendrogram(hc) dend <- color_labels(dend, 5, col = c(3, 1, 1, 4, 1)) dend <- color_branches(dend, 5, col = c(3, 1, 1, 4, 1)) plot(dend) # selective coloring of branches AND labels :) # coloring some labels, based on label names: dend <- color_labels(dend, col = "red", labels = labels(dend)[c(4, 16)]) plot(dend) # selective coloring of branches AND labels :) d5 <- color_branches(dend, 5) plot(d5) d5g <- color_branches(dend, 5, groupLabels = TRUE) plot(d5g) d5gr <- color_branches(dend, 5, groupLabels = as.roman) plot(d5gr) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.