我有一系列ggplot
s 我想按如下所示排列并插入到通过knitr
. 而不是一个非常小的肖像人物,我想把它旋转成横向,这样它就可以尽可能地填满页面。有任何想法吗?
library(ggplot2)
library(grid)
df <- data.frame(x = 1:100, y =rnorm(100))
plota <- ggplot(df, aes(x, y)) + geom_point(size = 4)
pushViewport(viewport(layout = grid.layout(3, 5)))
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
print(plota, vp = vplayout(1:2, 1:2))
print(plota, vp = vplayout(1, 3))
print(plota, vp = vplayout(1, 4))
print(plota, vp = vplayout(1, 5))
print(plota, vp = vplayout(2, 3))
print(plota, vp = vplayout(2, 4))
print(plota, vp = vplayout(2, 5))
print(plota, vp = vplayout(3, 1))
print(plota, vp = vplayout(3, 2))
print(plota, vp = vplayout(3, 3))
print(plota, vp = vplayout(3, 4))
print(plota, vp = vplayout(3, 5))