rep_geom | R Documentation |
Helper to repeat a geom multiple times swapping in different columns or constant values. Useful for things like drawing a white underdrawing beneath a layer.
rep_geom(geom_call, ...)
geom_call |
A geom layer with an aesthetics mapping. |
... |
A named series of values to use for aesthetic mappings. |
list of geoms
## Not run:
rep_geom(geom_line(aes(x = x, y = y),
linewidth = c(3, 1),
color = c("white", color_group)))
# == is the same as ==>
list(
geom_line(aes(x = x, y = y), linewidth = 3, color = "white"),
geom_line(aes(x = x , y = y, color = color_grp), linewidth = 3)
)
# color is recycled to the length of the other aesthetics
ggplot(mtcars, aes(x = drat, y = mpg)) +
rep_geom(geom_point(shape = 21),
size = c(8, 6, 2),
fill = c("gray80", am, "red"),
color = "yellow")
# use !! when passing a variable containing a constant value
foo <- "green"
ggplot(mtcars, aes(x = drat, y = mpg)) +
rep_geom(geom_point(shape = 21),
size = c(8, 6, 2),
fill = c(!!foo, am, "red"), # <- just passing foo won't work
color = "yellow")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.