Debian Codegraph @

man/plot_horiz.dendrogram.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/tanglegram.R
3 \name{plot_horiz.dendrogram}
4 \alias{plot_horiz.dendrogram}
5 \title{Plotting a left-tip-adjusted horizontal dendrogram}
6 \source{
7 This function is based on replicating \link{plot.dendrogram}.
8 In fact, I'd be happy if in the future, some tweaks could be make to
9 \link{plot.dendrogram}, so that it would replace the need for this function.
10 }
11 \usage{
12 plot_horiz.dendrogram(
13 x,
14 type = c("rectangle", "triangle"),
15 center = FALSE,
16 edge.root = is.leaf(x) || !is.null(attr(x, "edgetext")),
17 dLeaf = NULL,
18 horiz = TRUE,
19 xaxt = "n",
20 yaxt = "s",
21 xlim = NULL,
22 ylim = NULL,
23 nodePar = NULL,
24 edgePar = list(),
25 leaflab = c("perpendicular", "textlike", "none"),
26 side = TRUE,
27 text_pos = 2,
28 ...
29 )
30 }
31 \arguments{
32 \item{x}{tree object (dendrogram)}
33
34 \item{type}{a character vector with either "rectangle" or "triangle" (passed to \link{plot.dendrogram})}
35
36 \item{center}{logical; if TRUE, nodes are plotted centered with respect to
37 the leaves in the branch. Otherwise (default), plot them in the
38 middle of all direct child nodes.}
39
40 \item{edge.root}{logical; if true, draw an edge to the root node.}
41
42 \item{dLeaf}{a number specifying the distance in user coordinates between
43 the tip of a leaf and its label. If NULL as per default, 3/4 of a letter
44 width is used.}
45
46 \item{horiz}{logical indicating if the dendrogram should be
47 drawn horizontally or not. In this function it MUST be TRUE!}
48
49 \item{xaxt}{graphical parameters, or arguments for other methods.}
50
51 \item{yaxt}{graphical parameters, or arguments for other methods.}
52
53 \item{xlim}{(NULL) optional x- and y-limits of the plot, passed to plot.default.
54 The defaults for these show the full dendrogram.}
55
56 \item{ylim}{(NULL) optional x- and y-limits of the plot, passed to plot.default.
57 The defaults for these show the full dendrogram.}
58
59 \item{nodePar}{NULL.}
60
61 \item{edgePar}{list()}
62
63 \item{leaflab}{c("perpendicular", "textlike", "none")}
64
65 \item{side}{logical (TRUE). Should the tips of the drawn tree be facing
66 the left side. This is the important feature of this function.}
67
68 \item{text_pos}{integer from either 1 to 4 (2). Two relevant values
69 are 2 and 4. 2 (default) means that the labels are alligned to the
70 tips of the tree leaves. 4 will have the labels allign to the left,
71 making them look like they were when the tree was on the left side
72 (with leaves tips facing to the right).}
73
74 \item{...}{passed to \link{plot}.}
75 }
76 \value{
77 The invisiable dLeaf value.
78 }
79 \description{
80 The default \code{plot(dend, horiz = TRUE)}, gives us a dendrogram tree plot
81 with the tips turned right. The current function enables the creation of
82 the same tree, but with the tips turned left. The main challange in doing this
83 is finding the distance of the labels from the leaves tips - which is solved
84 with this function.
85 }
86 \examples{
87 \dontrun{
88 dend <- USArrests[1:10, ] \%>\%
89 dist() \%>\%
90 hclust() \%>\%
91 as.dendrogram()
92
93 par(mfrow = c(1, 2), mar = rep(6, 4))
94 plot_horiz.dendrogram(dend, side = FALSE)
95 plot_horiz.dendrogram(dend, side = TRUE)
96 # plot_horiz.dendrogram(dend, side=TRUE, dLeaf= 0)
97 # plot_horiz.dendrogram(dend, side=TRUE, nodePar = list(pos = 1))
98 # sadly, lab.pos is not implemented yet,
99 ## so the labels can not be right aligned...
100
101
102 plot_horiz.dendrogram(dend, side = F)
103 plot_horiz.dendrogram(dend, side = TRUE, dLeaf = 0, xlim = c(100, -10)) # bad
104 plot_horiz.dendrogram(dend, side = TRUE, text_offset = 0)
105 plot_horiz.dendrogram(dend, side = TRUE, text_offset = 0, text_pos = 4)
106 }
107 }
108 \seealso{
109 \link{plot.dendrogram}, \link{tanglegram}
110 }