View source: R/draw_key_fields.r
draw_key_fields | R Documentation |
Each geom has an associated function that draws the key when the geom needs
to be displayed in a legend. These functions are called draw_key_*()
, where
*
stands for the name of the respective key glyph. The key glyphs can be
customized for individual geoms by providing a geom with the key_glyph
argument (see layer()
or examples below.)
draw_key_fields(data, params, size)
data |
A single row data frame containing the scaled aesthetics to display in this key |
params |
A list of additional parameters supplied to the geom. |
size |
Width and height of key in mm. |
The layer geom_fields()
allows for a special aesthetic radius
. This function
draws a key glyph for this aesthetics, where the radius of the arrow corresponds
with the scalar value listed with this radius. Note that the width of the key glyph
cannot be adjusted by the aesthetic itself. Therefore, if your max_radius
parameter
exceeds the glyph width, you need to change the width of the guides yourself,
see vignette("radius_aes")
for more details.
A grid grob
Pepijn de Vries
if (requireNamespace("ggplot2")) {
library(ggplot2)
p <- ggplot(economics, aes(date, psavert, color = "savings rate"))
p + geom_line(key_glyph = "fields")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.