The multiplot
function is defined here in the cookbook
Consider the following graphs.
p1 = ggplot(mtcars,aes(y=mpg, x=cyl)) + geom_point()
p2 = ggplot(mtcars,aes(y=disp, x=cyl)) + geom_point()
multiplot(p1,p2, layout=matrix(1:2,nrow=1))
I'd like to manipulate (with function DoStuff
) the plot as a gtable
object rather than as a ggplot
object.
g1 = ggplot_gtable(ggplot_build(p1))
g1 = DoStuff(g1)
g2 = ggplot_gtable(ggplot_build(p1))
g2 = DoStuff(g2)
I can print a gtable with grid.draw
.
How can I modify the multiplot function, so that it also accepts gtable
objects and not just ggplot
objects?