Debian Codegraph @

man/color_labels.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/color_branches.R
3 \name{color_labels}
4 \alias{color_labels}
5 \alias{colour_labels}
6 \title{Color dend's labels according to sub-clusters}
7 \source{
8 This function is in the style of \code{\link{color_branches}}, and
9 based on \code{\link{labels_colors}}.
10 }
11 \usage{
12 color_labels(
13 dend,
14 k = NULL,
15 h = NULL,
16 labels,
17 col,
18 warn = dendextend_options("warn"),
19 ...
20 )
21 }
22 \arguments{
23 \item{dend}{A \code{dendrogram} or \code{hclust} tree object}
24
25 \item{k}{number of groups (passed to \code{\link[dendextend]{cutree}})}
26
27 \item{h}{height at which to cut tree (passed to \code{\link[dendextend]{cutree}})}
28
29 \item{labels}{character vecotor. If not missing, it overrides k and h,
30 and simply colors these labels in the tree based on "col" parameter.}
31
32 \item{col}{Function or vector of Colors. By default it tries to use
33 \link[colorspace]{rainbow_hcl} from the \code{colorspace} package.
34 (with parameters c=90 and l=50). If \code{colorspace} is not available,
35 It will fall back on the \link{rainbow} function.}
36
37 \item{warn}{logical (default from dendextend_options("warn") is FALSE).
38 Set if warning are to be issued, it is safer to keep this at TRUE,
39 but for keeping the noise down, the default is FALSE.
40 (in case h/k/labels are not supplied, or if col is too short)}
41
42 \item{...}{ignored.}
43 }
44 \value{
45 a tree object of class dendrogram.
46 }
47 \description{
48 This function is for dendrogram and hclust objects.
49 This function colors tree's labels.
50
51 The groups will be defined by a call to \code{\link[dendextend]{cutree}}
52 using the k or h parameters.
53
54 If col is a color vector with a different length than the number of clusters
55 (k) - then a recycled color vector will be used.
56 }
57 \examples{
58
59 \dontrun{
60 hc <- hclust(dist(USArrests), "ave")
61 dend <- as.dendrogram(hc)
62 dend <- color_labels(dend, 5, col = c(3, 1, 1, 4, 1))
63 dend <- color_branches(dend, 5, col = c(3, 1, 1, 4, 1))
64 plot(dend) # selective coloring of branches AND labels :)
65
66 # coloring some labels, based on label names:
67 dend <- color_labels(dend, col = "red", labels = labels(dend)[c(4, 16)])
68 plot(dend) # selective coloring of branches AND labels :)
69
70 d5 <- color_branches(dend, 5)
71 plot(d5)
72 d5g <- color_branches(dend, 5, groupLabels = TRUE)
73 plot(d5g)
74 d5gr <- color_branches(dend, 5, groupLabels = as.roman)
75 plot(d5gr)
76 }
77
78 }
79 \seealso{
80 \code{\link[dendextend]{cutree}},\code{\link{dendrogram}},
81 \code{\link{hclust}}, \code{\link{labels_colors}}, \code{\link{color_branches}},
82 \link{assign_values_to_leaves_edgePar}
83 }