R 版本 3.2.2 下 arrangeGrob 的问题

problems with arrangeGrob under R version 3.2.2

我已经更新了我的 R 版本,包括所有包和函数 arrangeGrob (Package gridExtra) 已经改变。

在我的旧版本 R 版本 3.1.3 上,我使用它如下制作角标:

正在加载 r 包

library(ggplot2)
library(grid)
library(gridExtra)

示例数据

a <- 1:20
b <- sample(a, 20)
c <- sample(b, 20)
d <- sample(c, 20)

创建数据框

mydata   <- data.frame(a, b, c, d)

创建示例图

myplot1  <- ggplot(mydata, aes(x=a, y=b)) + geom_point()
myplot2  <- ggplot(mydata, aes(x=b, y=c)) + geom_point()
myplot3  <- ggplot(mydata, aes(x=c, y=d)) + geom_point()
myplot4  <- ggplot(mydata, aes(x=d, y=a)) + geom_point()

设置角标签

 myplot1 <- arrangeGrob(myplot1, main = textGrob("A", x = unit(0, "npc")
     , y   = unit(1, "npc"), just=c("left","top"),
     gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))

 myplot2 <- arrangeGrob(myplot2, main = textGrob("B", x = unit(0, "npc")
     , y = unit(1, "npc"), just=c("left","top"),
     gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))

 myplot3 <- arrangeGrob(myplot3, main = textGrob("C", x = unit(0, "npc")
    , y  = unit(1, "npc"), just=c("left","top"),
    gp=gpar(col="black", fontsize=18, fontfamily="Times Roman")))

 myplot4 <- arrangeGrob(myplot4, main = textGrob("D", x = unit(0, "npc")
    , y = unit(1, "npc"), just=c("left","top"),
    gp=gpar(col="black",    fontsize=18, fontfamily="Times Roman")))

 grid.arrange(myplot1, myplot2, myplot3, myplot4) 

我得到了以下情节,很好:

但在新的 R 版本 3.2.2 下图像看起来像这样:

arrangeGrob 为每个 textGrob 打开一张新图片,我在一页上有八张图片而不是四张。我怎样才能解决这个问题,使情节看起来像旧版本的 R 和 gridExtra?

来自 Kev 的评论:

There has been a rewrite of gridExtra, that is not (fully) backward compatible - may be the issue. Have a look at the new wiki cran.r-project.org/web/packages/gridExtra/vignettes/… . Try changing main to top – user20650