Reputation: 57
I have some lists of plots named p1,p2,p3, each one contains c plots (c is a constant number). I would like to use grid.arrange as follow:
grid.arrange(p1[1],...,p1[c],p2[1],...,p2[c],p3[1],...,p3[c],ncol=2)
I tried to the following commands but they do not work:
do.call("grid.arrange",c(p1,p2,p3,ncol=2))
or
do.call("grid.arrange",c(list(unlist(p1),unlist(p2),unlist(p3)),ncol=2))
But the interesting thing is the following command works (but not really what I want)
do.call("grid.arrange",c(p1,ncol=2))
So how can I arrange some lists of plots?
Upvotes: 0
Views: 621
Reputation: 26
No need for do.call,
library(ggplot2)
p1 = replicate(3, ggplot(), F)
p2 = replicate(5, ggplot(), F)
gridExtra::grid.arrange(grobs = c(p1, p2), ncol=2)
Upvotes: 1