限制格子图到视口?

时间:2011-02-01 14:38:13

标签: r plot viewport lattice r-grid

我想在现有情节的一个小区域中拟合整个格子图。

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")

有没有办法将晶格图限制在设备上的预定义区域,如上例所示?

1 个答案:

答案 0 :(得分: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 / library / grid / doc / grid.pdf),“将网格添加到网格”部分找到它。

enter image description here