2011-09-28 96 views
7

我在一个页面上有16个地块,排列在一个4x4的网格中。我想每个2x2的边框都有一个边框,但是不知道如何去做。围绕群组的边界

我最初使用layout(matrix(c(1,2,5,6,3,4,7,8,9,10,13,14,11,12,15,16), 4, 4, byrow=TRUE))来创建正确的布局,但据我所知,没有办法创建超出当前图和任何后续图的边界将重叠的边界。

我试过的第二种方法是使用split.screen(),认为任何oma()设置只适用于当前屏幕,但它似乎适用于整个窗口;例如,下面的代码在整个显示区域,而不是screen(1)的外产生的边界:

depths <- c(1:10) 
split.screen(c(2,2)) 
screen(1) 
par(oma=c(1,1,1,1)) 
plot(depths) 
box("inner", lty="dotted", col="green") 

试图与任一box("inner")box("outer")各种事情设定oma设置不会产生所希望的结果后。

有没有其他明显的方法我应该尝试?

谢谢,
克里斯

回答

5

下面是一个使用布局方式:

layout(matrix(c(1,2,5,6,3,4,7,8,9,10,13,14,11,12,15,16), 4, 4, byrow=TRUE)) 
replicate(16, hist(rnorm(100))) 
par(xpd=NA) 
rect(grconvertX(0.005, from='ndc'), grconvertY(0.505, from='ndc'), 
    grconvertX(0.495, from='ndc'), grconvertY(0.995, from='ndc')) 
rect(grconvertX(0.005, from='ndc'), grconvertY(0.005, from='ndc'), 
    grconvertX(0.495, from='ndc'), grconvertY(0.495, from='ndc')) 
rect(grconvertX(0.505, from='ndc'), grconvertY(0.505, from='ndc'), 
    grconvertX(0.995, from='ndc'), grconvertY(0.995, from='ndc')) 
rect(grconvertX(0.505, from='ndc'), grconvertY(0.005, from='ndc'), 
    grconvertX(0.995, from='ndc'), grconvertY(0.495, from='ndc')) 

它调整自己的喜好。

+0

非常好。想想我所有的时间都在浪费转换时间,那时候'grconvertX'就在那里。有一天我必须坐下来阅读基本功能列表。 – Aaron

6

尝试使用box("figure")

depths <- c(1:10) 
split.screen(c(2,2)) 
screen(1) 
box("figure") 
split.screen(c(2,2)) 
par(cex=0.5) 
screen(5) 
plot(depths)