-
Notifications
You must be signed in to change notification settings - Fork 2k
Alternative notation for multiple additions to a plot
Mara Averick edited this page Nov 2, 2018
·
5 revisions
Note: The ggplot2 wiki is no longer maintained, please use the ggplot2 website instead!
Perhaps useful, perhaps not.
add <- function(...) {dots <- list(...); Reduce("+", dots)} add(1, 2, 2) # 5
library(ggplot2) # usual version qplot(mpg, wt, data=mtcars, facets = vs ~ am) last_plot() + scale_colour_brewer(palette="Set1") + scale_x_continuous("x axis") # alternative notation qplot(mpg, wt, data=mtcars, facets = vs ~ am) add(last_plot(), scale_colour_brewer(palette="Set1"), scale_x_continuous("x axis")) # or qplot(mpg, wt, data=mtcars, facets = vs ~ am) last_plot() + list( scale_colour_brewer(palette="Set1"), scale_x_continuous("x axis") )