guide_axis_dendro {legendry} | R Documentation |
Dendrogram guide
Description
This axis is a speciality axis for discrete data that has been hierarchically clustered. Please be aware that the guide cannot affect the scale limits, which should be set appropriately. This guide will give misleading results when this step is skipped!
Usage
guide_axis_dendro(
key = "dendro",
title = waiver(),
theme = NULL,
labels = TRUE,
space = rel(10),
vanish = TRUE,
n.dodge = 1,
angle = waiver(),
check.overlap = FALSE,
ticks = "none",
axis_line = "none",
order = 0,
position = waiver()
)
Arguments
key |
A segment key specification. See more information
in the linked topic. Alternatively, an object of class
|
title |
A |
theme |
A |
labels , ticks , axis_line |
Guides to use as labels, ticks or axis lines. Can be specified as one of the following:
|
space |
Either a |
vanish |
Only relevant when the guide is used in the secondary theta
position: a |
n.dodge |
An positive |
angle |
A specification for the text angle. Compared to setting the
|
check.overlap |
A |
order |
A positive |
position |
A |
Value
A <Guide>
object.
See Also
Other standalone guides:
guide_axis_base()
,
guide_axis_nested()
,
guide_circles()
,
guide_colbar()
,
guide_colring()
,
guide_colsteps()
,
guide_legend_base()
,
guide_legend_cross()
,
guide_legend_group()
Examples
# Hierarchically cluster data
clust <- hclust(dist(scale(mtcars)), "ave")
# Using the guide along with appropriate limits
p <- ggplot(mtcars, aes(disp, rownames(mtcars))) +
geom_col() +
scale_y_discrete(limits = clust$labels[clust$order])
# Standard usage
p + guides(y = guide_axis_dendro(clust))
# Adding ticks and axis line
p + guides(y = guide_axis_dendro(clust, ticks = "ticks", axis_line = "line")) +
theme(axis.line = element_line())
# Controlling space allocated to dendrogram
p + guides(y = guide_axis_dendro(clust, space = unit(4, "cm"))) +
theme(axis.ticks.y.left = element_line("red"))
# If want just the dendrogram, use `labels = FALSE`
p + guides(y = guide_axis_dendro(clust, labels = FALSE), y.sec = "axis")