我想在现有情节的一个小区域中拟合整个格子图。
xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a")
pushViewport(viewport(.2, .7, .2, .2))
grid.rect(gp=gpar(fill="white"))
给了我这个:
因此推送了视口。但是,如果再次调用晶格函数,它将使用整个器件,就像调用grid.newpage()
:
xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos, type = "a")
有没有办法将晶格图限制在设备上的预定义区域,如上例所示?
答案 0 :(得分:6)
您必须直接调用print
,newpage
参数设置为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),“将网格添加到网格”部分找到它。