6
我有一系列ggplot
s,我想按照下圖所示進行排列,並插入到通過knitr
解析的文檔中。我不希望有一個非常小的肖像人物,而是希望將它旋轉爲橫向,以便儘可能地填充頁面。有任何想法嗎?如何將ggplot旋轉到橫向?
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))
謝謝儀輝,很多apprecciated。 – Maiasaura