library(ggplot2)
df <- data.frame(x=1:10, y=rnorm(10))
p1 <- ggplot(df, aes(x,y)) + geom_point()
plist <- list(p1,p1,p1,p1,p1)
# In my real example,a plot function will fit a ggplot to a list of datasets
#and return a list of ggplots like the example above.
我想用 grid.arrange ()
在 gridExtra
中安排地块。
如果 plist
中的地块数量是变量, 我将怎么做?
This works:
grid.arrange(plist[[1]],plist[[2]],plist[[3]],plist[[4]],plist[[5]])
但我需要一个更普遍的解决方案。 想法呢?