Debian Codegraph @

man/hang.dendrogram.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/attr_access.R
3 \name{hang.dendrogram}
4 \alias{hang.dendrogram}
5 \title{Hang dendrogram leaves}
6 \source{
7 Noticing that as.dendrogram has a "hang" parameter was thanks to Enrique Ramos's answer here::
8 \url{https://stackoverflow.com/questions/17088136/plot-horizontal-dendrogram-with-hanging-leaves-r}
9 }
10 \usage{
11 hang.dendrogram(dend, hang = 0.1, hang_height, ...)
12 }
13 \arguments{
14 \item{dend}{a dendrogram object}
15
16 \item{hang}{The fraction of the plot height by which labels should hang below
17 the rest of the plot. A negative value will cause the labels to
18 hang down from 0.}
19
20 \item{hang_height}{is missing, then using "hang". If a number is given,
21 it overrides "hang" (except if "hang" is negative)}
22
23 \item{...}{not used}
24 }
25 \value{
26 A dendrogram, after adjusting the height attr in all of its leaves,
27 so that the tree will hang.
28 }
29 \description{
30 Adjust the height attr in all of the dendrogram leaves so that
31 the tree will hang. This is similar to as.dendrogram(hclust, hang=0.1)
32 Only that it now works on other object than hclust turned into a dendrogram.
33 For example, this allows us to hang non-binary trees.
34 }
35 \examples{
36
37 # define dendrogram object to play with:
38 hc <- hclust(dist(USArrests[1:5, ]), "ave")
39 dend <- as.dendrogram(hc)
40
41 par(mfrow = c(1, 2))
42 plot(hang.dendrogram(dend))
43 plot(hc)
44 # identical(as.dendrogram(hc, hang = 0.1), hang.dendrogram(dend, hang = 0.1))
45 # TRUE!!
46
47
48 par(mfrow = c(1, 4))
49
50 plot(dend)
51 plot(hang.dendrogram(dend, hang = 0.1))
52 plot(hang.dendrogram(dend, hang = 0))
53 plot(hang.dendrogram(dend, hang = -0.1))
54
55 par(mfrow = c(1, 1))
56 plot(hang.dendrogram(dend), horiz = TRUE)
57 }