Learn R Programming

ggtern (version 1.0.5.0)

ggtern.multi: Arrange Multiple Plot Objects

Description

ggtern.multi is a function which permits the arrangement of muliple ggtern or ggplot2 objects, plots can be provided to the elipsis argument, or, as a list and at the simplest case, the number of columns can be specified. For more advanced usage, consider the layout argument.

Usage

ggtern.multi(..., plotlist = NULL, cols = 1, layout = NULL)

Arguments

...
multiple plot objects
plotlist
alternative to the ... argument, provide a list of ggplot or grob objects, objects which do not inherit the ggplot or grob classes will be stripped.
cols
number of columns if the layout parameter is not provided.
layout
override number of cols, and provide a matrix specifying the layout

source

http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/

Details

By default, 1 column is specified, which means that the plots will be stacked on top of each other in a single column, however, if say 4 plots are provided to the ellipsis or plotlist, with cols equal to 2, then this will produce a 2 x 2 arrangement.

In regards to the layout argument (which overrides the cols argument), if it is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), then plot number 1 will go in the upper left, 2 will go in the upper right, and 3 will go all the way across the bottom - see the last example below.

Examples

Run this code
data(Feldspar)
 p <- ggtern(data=Feldspar,aes(Ab,An,Or)) + geom_point() + labs(title="Multiple Plot Example")

 #two cols
 ggtern.multi(p,p,cols=2)

 ##Below are some alternatives, uncomment to run
 #ggtern.multi(plotlist=list(p,p,p))
 #ggtern.multi(p,p,p,layout=matrix(c(1,1,2,3), nrow=2,byrow=TRUE))

Run the code above in your browser using DataLab