2014-02-21 76 views
0

我有一對夫婦ggplot陰謀,我想用grid.arrange()調整距離

當我合併的地塊有圍繞每個小區大面積的白色使他們遠離彼此合併。

有沒有辦法調整圖之間的距離?和地塊周圍的白色區域的大小?

回答

1

您可以使用ggplot2中的theme(plot.margin)函數來減小間距。

一個簡單的工作示例這裏:

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

x <- seq(1,10,1) 
y <- dnorm(x,mean=10,sd=0.5) 


# Create p1 
p1 <- qplot(x,y) + theme(plot.margin=unit(c(1,1,-0.5,1),"cm")) 

# Create p2 
p2 <- qplot(x,y) + theme(plot.margin=unit(c(-0.5,1,1,1),"cm")) 

grid.arrange(p1,p2) 

編輯 的4個數字是c(bottom,left,top,right)

樣本輸出

enter image description here

+0

你能解釋一下內單位的4個數字( )是指? – ghb

+0

編輯我的答案是指四個數字。 –