2011-02-01 19 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