ggplot2 - problems with arrangeGrob under R version 3.2.2 -
i 've updated r version including packages , function arrangegrob (package gridextra) has changed.
on old version r version 3.1.3 used following make corner labels:
loading r packages
library(ggplot2) library(grid) library(gridextra)
example data
a <- 1:20 b <- sample(a, 20) c <- sample(b, 20) d <- sample(c, 20)
create data frame
mydata <- data.frame(a, b, c, d)
create example plots
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()
set corner labels
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)
and got following plot, fine:
but under new r version 3.2.2 image looks this:
arrangegrob opens every textgrob new image , got 8 images on 1 page instead of four. how can fixed plot looks in old version of r , gridextra?
from kev's comment:
there has been rewrite of gridextra, not (fully) backward compatible - may issue. have @ new wiki cran.r-project.org/web/packages/gridextra/vignettes/… . try changing main top – user20650
Comments
Post a Comment