我正在使用 grid 包做一个多图图:
# load libraries
library(grid)
library(ggplot2)
library(gridSVG)
# create some data
p <- ggplot(mtcars, aes(wt, mpg))
# push Viewport and create layout
pushViewport(viewport(layout = grid.layout(nrow = 5, ncol = 4)))
matrixindex = cbind(rep(1:5,each =4), rep(1:4,times=5))
#fill viewport
for (k in 1:20){
print(p+geom_point(),
vp=viewport(layout.pos.row=matrixindex[k,1],layout.pos.col=matrixindex[k,2]))}
# export as SVG
gridToSVG("trial.svg","none","none")
现在,我想制作第二个图形,改变布局(只有一行,但又是 4 列)。但是图中的各个图应该具有与 5x4 布局中相同的大小。我怎样才能做到这一点?