在绘图中嵌入微型绘图 [英] Embedding a miniature plot within a plot
问题描述
有人知道将绘图嵌入其他绘图以生成类似于下面的模型的一般方法吗?
我知道在格子中你可以使用 print(..., more=TRUE, position=...)
来做到这一点,如 在这里:http://cran.r-project.org/web/packages/gridBase/vignettes/gridBase.pdf
Does anybody know of a general way to embed plots into other plots to produce something like the mockup below?
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.
Thanks in advance!
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)
More detail here: http://casoilresource.lawr.ucdavis.edu/drupal/node/1007 And here: http://cran.r-project.org/web/packages/gridBase/vignettes/gridBase.pdf
这篇关于在绘图中嵌入微型绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!