Learn R Programming

ggpubr (version 0.1.3)

ggarrange: Arrange Multiple ggplots

Description

Arrange multiple ggplots on the same page. Wrapper around plot_grid. Can arrange multiple ggplots over multiple pages.

Usage

ggarrange(..., plotlist = NULL, ncol = NULL, nrow = NULL, labels = NULL)

Arguments

...

list of plots to be arranged into the grid. The plots can be either ggplot2 plot objects or arbitrary gtables.

plotlist

(optional) list of plots to display.

ncol

(optional) number of columns in the plot grid.

nrow

(optional) number of rows in the plot grid.

labels

(optional) list of labels to be added to the plots. You can also set labels="AUTO" to auto-generate upper-case labels or labels="auto" to auto-generate lower-case labels.

Value

return an object of class ggarrange, which is a ggplot or a list of ggplot.

Examples

Run this code
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)

# Box plot
bxp <- ggboxplot(df, x = "dose", y = "len",
    color = "dose", palette = "jco")
# Dot plot
dp <- ggdotplot(df, x = "dose", y = "len",
    color = "dose", palette = "jco")
# Density plot
dens <- ggdensity(df, x = "len", fill = "dose", palette = "jco")

ggarrange(bxp, dp, dens, ncol = 2, nrow = 2)

Run the code above in your browser using DataLab