问题描述
有人知道将地块嵌入其他地块以产生类似下面的模型的一般方法吗?
Does anybody know of a general way to embed plots into other plots to produce something like the mockup below?
我知道您可以按照此说明在晶格中使用print(..., more=TRUE, positions=...)
来完成此操作问题,我想ggplot也可以解决这个问题(但我对ggplot不太满意).问题是我想将使用标准图形包的生存包中的规则图嵌入到格子图中.
I know that in lattice you can do it with print(..., more=TRUE, positions=...)
as explained in this question, and I guess ggplot has a solution to it aswell (but I'm not very good with ggplot). The problem is that I want to embed a regular plot from the survival package that use the standard graphics package into a lattice plot.
提前谢谢!
推荐答案
您可以尝试使用gridBase软件包,该软件包提供了一些功能,用于集成基础图形和基于网格的图形(包括grid和ggplot2).下面的示例将基本图形图嵌入晶格图内.
You could try the gridBase package which provides some functionality for integrating base and grid-based graphics (including lattice and ggplot2). The example below embeds a base graphics plot inside of a lattice plot.
library(lattice)
library(gridBase)
library(grid)
plot.new()
pushViewport(viewport())
xvars <- rnorm(25)
yvars <- rnorm(25)
xyplot(yvars~xvars)
pushViewport(viewport(x=.6,y=.8,width=.25,height=.25,just=c("left","top")))
grid.rect()
par(plt = gridPLT(), new=TRUE)
plot(xvars,yvars)
popViewport(2)
此处有更多详细信息: http://casoilresource.lawr.ucdavis.edu/drupal/节点/1007 在这里: http://cran.r-project.org/web/packages/gridBase/vignettes/gridBase.pdf
More detail here: http://casoilresource.lawr.ucdavis.edu/drupal/node/1007And here: http://cran.r-project.org/web/packages/gridBase/vignettes/gridBase.pdf
这篇关于在地块中嵌入微型地块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!