2014-10-27 82 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