View source: R/guide-circles.R
guide_circles | R Documentation |
This guide displays the sizes of points as a series of circles. It is
typically paired with geom_point()
with
draw_key_point()
glyphs.
guide_circles(
key = NULL,
title = waiver(),
theme = NULL,
hjust = 0.5,
vjust = 0,
text_position = NULL,
clip_text = FALSE,
override.aes = list(shape = 1),
position = waiver(),
direction = NULL
)
key |
A standard key specification. Defaults to
|
title |
A |
theme |
A |
hjust , vjust |
A |
text_position |
A string, one of |
clip_text |
A |
override.aes |
A named |
position |
A |
direction |
A |
Please note that the default size scales scale to area, not radius, so equidistant breaks will appear at irregularly spaced positions due to labelling the diameter of a circle.
This graph was designed with standard round shapes
in mind, i.e. shapes 1, 16, 19 and 21. For that reason, shape = 1
is the
default override.aes
argument. Other shapes will probably be drawn but the
quality of their alignment and label placement may be unsatisfactory.
A <GuideCircles>
object.
Other standalone guides:
guide_axis_base()
,
guide_axis_dendro()
,
guide_axis_nested()
,
guide_colbar()
,
guide_colring()
,
guide_colsteps()
,
guide_legend_base()
,
guide_legend_cross()
,
guide_legend_group()
# A standard plot
p <- ggplot(mtcars, aes(disp, mpg)) +
geom_point(aes(size = hp), alpha = 0.3)
# By default, the sizes aren't large enough to make this guide clear
p + scale_size_area(guide = "circles")
# Update with a more approrpriate scale
p <- p +
scale_size_area(
max_size = 30,
limits = c(0, NA),
breaks = c(0, 25, 100, 250)
)
p + guides(size = "circles")
# Horizontal orientation
p + guides(size = guide_circles(
vjust = 0.5, hjust = 0, text_position = "bottom"
))
# Alternative text placement
p + guides(size = guide_circles(
text_position = "ontop",
clip_text = TRUE
))
# More styling options
p + guides(size = guide_circles(override.aes = aes(colour = "red")))+
theme(
# Key background
legend.key = element_rect(colour = "black", fill = 'white'),
# Padding around central shapes
legendry.legend.key.margin = margin(1, 1, 1, 1, "cm"),
legend.ticks = element_line(colour = "blue"),
legend.text.position = "left"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.