-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Alternative notation for multiple additions to a plot
Mara Averick edited this page Oct 30, 2018
·
5 revisions
- Note: The ggplot2 wiki is no longer maintained, please use the [ggplot2 website](https://ggplot2.tidyverse.org/) 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")
)