Debian Codegraph @

man/labels_colors.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/labels_colors.R
3 \name{labels_colors}
4 \alias{labels_colors}
5 \alias{labels_col}
6 \alias{labels_colors<-}
7 \title{Retrieve/assign colors to the labels of a dendrogram}
8 \source{
9 Heavily inspired by the code in the example of \link{dendrapply},
10 so credit should go to Martin Maechler.
11 I also implemented some ideas from Gregory Jefferis's dendroextras package
12 (having the "names" of the returned vector be the labels).
13 }
14 \usage{
15 labels_colors(dend, labels = TRUE, ...)
16
17 labels_col(dend, labels = TRUE, ...)
18
19 labels_colors(dend, ...) <- value
20 }
21 \arguments{
22 \item{dend}{a dendrogram object}
23
24 \item{labels}{Boolean (default is TRUE), should the returned vector of colors
25 return with the leaves labels as names.}
26
27 \item{...}{not used}
28
29 \item{value}{a vector of colors to be used as new label's colors for the dendrogram}
30 }
31 \value{
32 A vector with the dendrogram's labels colors (or a colored dendrogram,
33 in case assignment is used). The colors are labeled.
34 }
35 \description{
36 Retrieve/assign colors to the labels of a dendrogram. Note that usually dend objects come without any color assignment (and the output will be NULL, until colors are assigned).
37 }
38 \examples{
39 # define dendrogram object to play with:
40 hc <- hclust(dist(USArrests[1:3, ]), "ave")
41 dend <- as.dendrogram(hc)
42
43 # Defaults:
44 labels_colors(dend)
45 plot(dend)
46
47 # let's add some color:
48 labels_colors(dend) <- 2:4
49 labels_colors(dend)
50 plot(dend)
51
52
53 # doesn't work...
54 # get_nodes_attr(dend, "nodePar", include_branches = FALSE)
55
56 # changing color to black
57 labels_colors(dend) <- 1
58 labels_colors(dend)
59 plot(dend)
60
61 # removing color (and the nodePar completely - if it has no other attributed but lab.col)
62 suppressWarnings(labels_colors(dend) <- NULL)
63 labels_colors(dend)
64 plot(dend)
65 }
66 \seealso{
67 \code{\link[dendextend]{cutree}},\code{\link{dendrogram}},
68 \code{\link{hclust}}, \code{\link{color_labels}}, \code{\link{color_branches}},
69 \link{assign_values_to_leaves_edgePar}, \link{get_leaves_branches_col}
70 }