2011-02-01 57 views
6

我想在现有地块的一个小区域中拟合整个格子图。将格子图限制到视口?

xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a") 
pushViewport(viewport(.2, .7, .2, .2)) 
grid.rect(gp=gpar(fill="white")) 

给了我这样的:

enter image description here

所以视推。但是,当如果一个格子函数被再次调用,它采用了全设备,仿佛呼唤grid.newpage()

xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a") 

有没有办法来格地块限制到预定区域的设备上如上面我的例子吗?

回答

6

你必须直接调用printnewpage参数设置为FALSE(相对于默认值):

xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a") 
pushViewport(viewport(.2, .7, .2, .2)) 
print(xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a"), newpage=FALSE) 

你可以手动电网中找到它(r_instalation_path /库/格/ DOC/grid.pdf) ,“将网格添加到网格”一节。

enter image description here