2014-10-27 48 views
0

到目前为止,Ive被看见只解决方案绘制在一个面板多个附图其与奇数拉伸曲线中的一个(或全部)的行中:多条曲线:布局(矩阵)不拉伸曲线

m <- matrix(c(1,2,3,4,5,5), nrow = 2, ncol = 3, byrow=TRUE) 
layout(m) 
plot(rnorm(100)) 
plot(rnorm(100)) 
plot(rnorm(100)) 
plot(rnorm(100)) 
plot(rnorm(100)) 

最后一个子图被拉伸到剩下的atrix行的长度。 现在,编号喜欢有第二行中的两个图在中心对齐(例如:http://jpgraph.net/download/manuals/chunkhtml/images/matrix_layout_ex1.png例如)。

这可能吗?

回答

2

你不能用layout做到这一点。然而split.screen更加灵活:

#split screen in two rows: 
split.screen(c(2, 1)) 
#split first row in three columns: 
split.screen(c(1, 3), screen = 1) 
#split second row in two screens with specific dimensions: 
split.screen(matrix(c(1/6, 0.5, #left 
         0.5, 5/6, #right 
         0, 0,  #bottom  
         1, 1),  #top 
        ncol=4), 
      screen=2) 

#now fill the screens 
screen(3) 
plot(rnorm(100)) 
screen(4) 
plot(rnorm(100)) 
screen(5) 
plot(rnorm(100)) 
screen(6) 
plot(rnorm(100)) 
screen(7) 
plot(rnorm(100)) 
close.screen(all = TRUE) 

resulting plot