Learn R Programming

Laurae (version 0.0.0.9001)

grid_arrange_shared_legend: ggplot multiple plot per page

Description

This function allows to plot multiple ggplot plots in the same page while keepin the same legend.

Usage

grid_arrange_shared_legend(..., ncol = length(list(...)), nrow = 1,
  position = c("bottom", "right"))

Arguments

...
Type: ggplot. Input any ggplot you want.
ncol
Type: integer. The number of columns in your final page. Defaults to "length(list(...))".
nrow
Type: itneger The number of rows in your final page. Defaults to 1.
position
Type: character. Where to put the legend. Defaults to c("bottom", "right")

Value

The requested ggplots in the same page.

Examples

Run this code
## Not run: ------------------------------------
# dataset(mtcars)
# p1 <- ggplot(mtcars, aes(x = mpg, y = as.factor(cyl), fill = vs)) + geom_point()
# p2 <- ggplot(mtcars, aes(x = mpg, y = as.factor(cyl), fill = vs)) + geom_boxplot()
# grid_arrange_shared_legend(p1, p2)
## ---------------------------------------------

Run the code above in your browser using DataLab