SciencesPo (version 1.3.8)

multiplot: Multiple ggplot objects

Description

ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)

Usage

multiplot(..., ncols = 1, layout = NULL)

Arguments

ncols
number of columns in layout
layout
a matrix specifying the layout. If present, 'ncols' is ignored.
...
a list of ggplot objects

encoding

UTF-8

Details

If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), then plot 1 will go in the upper left, 2 will go in the upper right, and 3 will go all the way across the bottom.

Examples

Run this code
# Load the diamonds dataset
data(diamonds)
# Create a histogram, assign to "plot1"
plot1 <- qplot(price,data=diamonds,binwidth=1000)
 # Create a scatterplot
plot2 <- qplot(carat,price,data=diamonds)
# Arrange and display the plots into a 1x2 grid
multiplot(plot1, plot2, ncols=2)

Run the code above in your browser using DataLab