Visual representation of a discrete variable with hierarchical relationships
between members, like those detailed in
scale_(x|y)_dendrogram)()
. This function is
deprecated in favour of legendry::guide_axis_dendro()
.
A character string or expression indicating a title of guide.
If NULL
, the title is not shown. By default
(waiver()
), the name of the scale object or the name
specified in labs()
is used for the title.
silently remove overlapping labels, (recursively) prioritizing the first, last, and middle labels.
The number of rows (for vertical axes) or columns (for horizontal axes) that should be used to render the labels. This is useful for displaying labels that would otherwise overlap.
A positive integer
of length 1 that specifies the order of
this guide among multiple guides. This controls in which order guides are
merged if there are multiple guides for the same position. If 0 (default),
the order is determined by a secret algorithm.
Where this guide should be drawn: one of top, bottom, left, or right.
A logical(1)
. If TRUE
, labels are drawn at the
dendrogram leaves. If FALSE
, labels are not drawn.
The lower and upper range of the truncated axis:
NULL
to not perform any truncation.
A function
that takes the break positions as input and returns the lower
or upper boundary. Note that also for discrete scales, positions are the
mapped positions as numeric
.
A numeric
value in data units for the lower and upper boundaries.
A unit
object.
A character(1)
with a valid colour for colouring the
axis text, axis ticks and axis line. Overrules the colour assigned by the
theme.
Relevant plotting data for a dendrogram such as those returned
by ggdendro::dendro_data()
.
A dendroguide class object.
The dendrogram guide inherits graphical elements from the
axis.ticks
theme element. However, the size of the dendrogram is set
to 10 times the axis.ticks.length
theme element.
clust <- hclust(dist(USArrests), "ave")
# Melting USArrests
df <- data.frame(
State = rownames(USArrests)[row(USArrests)],
variable = colnames(USArrests)[col(USArrests)],
value = unname(do.call(c, USArrests))
)
# The guide function can be used to customise the axis
g <- ggplot(df, aes(variable, State, fill = value)) +
geom_raster() +
scale_y_dendrogram(hclust = clust,
guide = guide_dendro(n.dodge = 2))
#> Warning: `scale_y_dendrogram()` was deprecated in ggh4x 0.3.0.
#> ℹ Please use `legendry::scale_y_dendro()` instead.
#> Warning: `guide_dendro()` was deprecated in ggh4x 0.3.0.
#> ℹ Please use `legendry::guide_axis_dendro()` instead.
# The looks of the dendrogram are controlled through ticks
g + theme(axis.ticks = element_line(colour = "red"))
# The size of the dendrogram is controlled through tick size * 10
g + theme(axis.ticks.length = unit(5, "pt"))