I want to save, but not print (for now), a bunch of ggplot()
s into a grid (via arrangeGrob()
, correct?), then print and retrieve them later.
This is a reboot of an existing question.
Strangely, that answer does not work, and I have no idea why.
I am using the exact same code.
library(ggplot2)
p1 <- ggplot(mtcars, aes(x=factor(cyl), y=mpg)) + geom_boxplot()
p2 <- ggplot(mtcars, aes(x=factor(cyl), y=wt)) + geom_boxplot()
library(gridExtra)
y <- arrangeGrob(p1, p2)
class(y)
y
Strangely, that does not (as in the above answer) yield the grid of plots, but:
> class(y)
[1] "gtable" "grob" "gDesc"
> y
TableGrob (2 x 1) "arrange": 2 grobs
z cells name grob
1 1 (1-1,1-1) arrange gtable[layout]
2 2 (2-2,1-1) arrange gtable[layout]
What is going on here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…