]> git.donarmstrong.com Git - ape.git/blob - man/nodelabels.Rd
9a7f51a96c1a7ac9deefb3b631fb2cc8eda31fa3
[ape.git] / man / nodelabels.Rd
1 \name{nodelabels}
2 \alias{nodelabels}
3 \alias{tiplabels}
4 \alias{edgelabels}
5 \title{Labelling the Nodes, Tips, and Edges of a Tree}
6 \description{
7   These functions add labels to or near the nodes, the tips, or the
8   edges of a tree using text or plotting symbols. The text can be
9   framed.
10 }
11 \usage{
12 nodelabels(text, node, adj = c(0.5, 0.5), frame = "rect",
13            pch = NULL, thermo = NULL, pie = NULL, piecol = NULL,
14            col = "black", bg = "lightblue", horiz = FALSE,
15            width = NULL, height = NULL, ...)
16 tiplabels(text, tip, adj = c(0.5, 0.5), frame = "rect",
17           pch = NULL, thermo = NULL, pie = NULL, piecol = NULL,
18           col = "black", bg = "yellow", horiz = FALSE,
19           width = NULL, height = NULL, ...)
20 edgelabels(text, edge, adj = c(0.5, 0.5), frame = "rect",
21            pch = NULL, thermo = NULL, pie = NULL, piecol = NULL,
22            col = "black", bg = "lightgreen", horiz = FALSE,
23            width = NULL, height = NULL, ...)
24
25 }
26 \arguments{
27   \item{text}{a vector of mode character giving the text to be
28     printed. Can be left empty.}
29   \item{node}{a vector of mode numeric giving the numbers of the nodes
30     where the text or the symbols are to be printed. Can be left empty.}
31   \item{tip}{a vector of mode numeric giving the numbers of the tips
32     where the text or the symbols are to be printed. Can be left empty.}
33   \item{edge}{a vector of mode numeric giving the numbers of the edges
34     where the text or the symbols are to be printed. Can be left empty.}
35   \item{adj}{one or two numeric values specifying the horizontal and
36     vertical, respectively, justification of the text or symbols. By
37     default, the text is centered horizontally and vertically. If a
38     single value is given, this alters only the horizontal position of
39     the text.}
40   \item{frame}{a character string specifying the kind of frame to be
41     printed around the text. This must be one of "rect" (the default),
42     "circle", "none", or any unambiguous abbreviation of these.}
43   \item{pch}{a numeric giving the type of plotting symbol to be used;
44     this is eventually recycled. See \code{\link[graphics]{par}} for R's
45     plotting symbols. If \code{pch} is used, then \code{text} is
46     ignored.}
47   \item{thermo}{a numeric vector giving some proportions (values between
48     0 and 1) for each node, or a numeric matrix giving some proportions
49     (the rows must sum to one).}
50   \item{pie}{same than \code{thermo}.}
51   \item{piecol}{a list of colours (given as a character vector) to be
52     used by \code{thermo} or \code{pie}; if left \code{NULL}, a series
53     of colours given by the function \code{rainbow} is used.}
54   \item{col}{a character string giving the color to be used for the
55     text or the plotting symbols; this is eventually recycled.}
56   \item{bg}{a character string giving the color to be used for the
57     background of the text frames or of the plotting symbols if it
58     applies; this is eventually recycled.}
59   \item{\dots}{further arguments passed to the \code{text} or
60     \code{points} functions (e.g. \code{cex} to alter the size of the
61     text or the symbols, or \code{font} for the text; see the examples
62     below).}
63   \item{horiz, width, height}{parameters controlling the aspect of
64     thermometers; by default, their width and height are determined
65     automatically.}
66 }
67 \details{
68   These three functions have the same optional arguments and the same
69   functioning.
70
71   If the arguments \code{text} is missing and \code{pch} and
72   \code{thermo} are left as \code{NULL}, then the numbers of the nodes
73   (or of the tips) are printed.
74
75   If \code{node}, \code{tip}, or \code{edge} is missing, then the text
76   or the symbols are printed on all nodes, tips, or edges.
77
78   The option \code{cex} can be used to change the size of all types of
79   labels.
80
81   A simple call of these functions with no arguments (e.g.,
82   \code{nodelabels()}) prints the numbers of all nodes (or tips).
83
84   In the case of \code{tiplabels}, it would be useful to play with the
85   options \code{x.lim} and \code{label.offset} (and possibly
86   \code{show.tip.label}) of \code{plot.phylo} in most cases (see the
87   examples).
88 }
89 \author{Emmanuel Paradis, Ben Bolker \email{bolker@zoo.ufl.edu}, and Jim
90   Lemon}
91 \seealso{
92   \code{\link{plot.phylo}}, \code{\link{edges}},
93   \code{\link{mixedFontLabel}}
94 }
95 \examples{
96 tr <- read.tree(text = "((Homo,Pan),Gorilla);")
97 plot(tr)
98 nodelabels("7.3 Ma", 4, frame = "r", bg = "yellow", adj = 0)
99 nodelabels("5.4 Ma", 5, frame = "c", bg = "tomato", font = 3)
100
101 data(bird.orders)
102 plot(bird.orders, use.edge.length = FALSE, font = 1)
103 bs <- round(runif(22, 90, 100), 0) # some imaginary bootstrap values
104 bs2 <- round(runif(22, 90, 100), 0)
105 bs3 <- round(runif(22, 90, 100), 0)
106 nodelabels(bs, adj = 1.2)
107 nodelabels(bs2, adj = -0.2, bg = "yellow")
108
109 ### something more classical
110 plot(bird.orders, use.edge.length = FALSE, font = 1)
111 nodelabels(bs, adj = -0.2, frame = "n", cex = 0.8)
112 nodelabels(bs2, adj = c(1.2, 1), frame = "n", cex = 0.8)
113 nodelabels(bs3, adj = c(1.2, -0.2), frame = "n", cex = 0.8)
114
115 ### the same but we play with the font
116 plot(bird.orders, use.edge.length = FALSE, font = 1)
117 nodelabels(bs, adj = -0.2, frame = "n", cex = 0.8, font = 2)
118 nodelabels(bs2, adj = c(1.2, 1), frame = "n", cex = 0.8, font = 3)
119 nodelabels(bs3, adj = c(1.2, -0.2), frame = "n", cex = 0.8)
120
121 plot(bird.orders, "c", use.edge.length = FALSE, font = 1)
122 nodelabels(thermo = runif(22), cex = .8)
123
124 plot(bird.orders, "u", FALSE, font = 1, lab4ut = "a")
125 nodelabels(cex = .75, bg = "yellow")
126
127 ### representing two characters at the tips (you could have as many
128 ### as you want)
129 plot(bird.orders, "c", FALSE, font = 1, label.offset = 3,
130      x.lim = 31, no.margin = TRUE)
131 tiplabels(pch = 21, bg = gray(1:23/23), cex = 2, adj = 1.4)
132 tiplabels(pch = 19, col = c("yellow", "red", "blue"), adj = 2.5, cex = 2)
133 ### This can be used to highlight tip labels:
134 plot(bird.orders, font = 1)
135 i <- c(1, 7, 18)
136 tiplabels(bird.orders$tip.label[i], i, adj = 0)
137 ### Some random data to compare piecharts and thermometres:
138 tr <- rtree(15)
139 x <- runif(14, 0, 0.33)
140 y <- runif(14, 0, 0.33)
141 z <- runif(14, 0, 0.33)
142 x <- cbind(x, y, z, 1 - x - y - z)
143 layout(matrix(1:2, 1, 2))
144 plot(tr, "c", FALSE, no.margin = TRUE)
145 nodelabels(pie = x, cex = 1.3)
146 text(4.5, 15, "Are you \"pie\"...", font = 4, cex = 1.5)
147 plot(tr, "c", FALSE, no.margin = TRUE)
148 nodelabels(thermo = x, col = rainbow(4), cex = 1.3)
149 text(4.5, 15, "... or \"thermo\"?", font = 4, cex = 1.5)
150 plot(tr, "c", FALSE, no.margin = TRUE)
151 nodelabels(thermo = x, col = rainbow(4), cex = 1.3)
152 plot(tr, "c", FALSE, no.margin = TRUE)
153 nodelabels(thermo = x, col = rainbow(4), width = 3, horiz = TRUE)
154 layout(matrix(1))
155 plot(tr, main = "Showing Edge Lengths")
156 edgelabels(round(tr$edge.length, 3), srt = 90)
157 plot(tr, "p", FALSE)
158 edgelabels("above", adj = c(0.5, -0.25), bg = "yellow")
159 edgelabels("below", adj = c(0.5, 1.25), bg = "lightblue")
160 }
161 \keyword{aplot}