View source: R/guide-legend-base.R
guide_legend_base | R Documentation |
This legend closely mirrors ggplot2::guide_legend()
, but has two
adjustments. First, guide_legend_base()
supports a design
argument
for a more flexible layout. Secondly, the legend.spacing.y
theme element
is observed verbatim instead of overruled.
guide_legend_base(
key = NULL,
title = waiver(),
theme = NULL,
design = NULL,
nrow = NULL,
ncol = NULL,
reverse = FALSE,
override.aes = list(),
position = NULL,
direction = NULL,
order = 0
)
key |
A standard key specification. Defaults to
|
title |
A |
theme |
A |
design |
Specification of the legend layout. One of the following:
|
nrow , ncol |
A positive |
reverse |
A |
override.aes |
A named |
position |
A |
direction |
A |
order |
A positive |
A <GuideLegend>
object.
Other standalone guides:
guide_axis_base()
,
guide_axis_dendro()
,
guide_axis_nested()
,
guide_circles()
,
guide_colbar()
,
guide_colring()
,
guide_colsteps()
,
guide_legend_cross()
,
guide_legend_group()
Other legend guides:
guide_legend_cross()
,
guide_legend_group()
# A dummy plot
p <- ggplot(data.frame(x = 1:3, type = c("tic", "tac", "toe"))) +
aes(x, x, shape = type) +
geom_point(na.rm = TRUE) +
scale_shape_manual(values = c(1, 4, NA))
# A design string, each character giving a cell value.
# Newlines separate rows, white space is ignored.
design <- "
123
213
321
"
# Alternatively, the same can be specified using a matrix directly
# design <- matrix(c(1, 2, 3, 2, 1, 3, 3, 2, 1), 3, 3, byrow = TRUE)
p + guides(shape = guide_legend_base(design = design))
# Empty cells can be created using `#`
design <- "
#2#
1#3
"
# Alternatively:
# design <- matrix(c(NA, 1, 2, NA, NA, 3), nrow = 2)
p + guides(shape = guide_legend_base(design = design))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.