[R] lattice grob
baptiste auguie
baptiste.auguie at googlemail.com
Fri Mar 19 11:51:45 CET 2010
Dear list,
I'm trying to arrange various grid objects on a page using a
frameGrob. It works fine with basic grobs (textGrob, gTree, etc.), and
also with ggplot2 objects using the ggplotGrob() function. I am
however stuck with lattice. As far as I understand, lattice produces a
list of class trellis, which is eventually displayed using the
plot.trellis method. I am not sure if/how one can convert this list
into a high-level grob. I tried the following,
latticeGrob <- function(p, ...){
grob(p=p, ..., cl="lattice")
}
drawDetails.lattice <- function(x, recording=FALSE){
lattice:::plot.trellis(x$p)
}
p1 <- xyplot(1:10 ~ 1:10)
g1 <- latticeGrob(p1)
grid.draw(g1) # works fine
but,
fg <- frameGrob(layout = grid.layout(1,1))
fg <- placeGrob(fg, g1, row = 1, col = 1)
grid.draw(fg)
Error in UseMethod("depth") :
no applicable method for 'depth' applied to an object of class "NULL"
Ideas are most welcome,
Best regards,
baptiste
> sessionInfo()
R version 2.10.1 RC (2009-12-06 r50690)
i386-apple-darwin9.8.0
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] grid tools stats graphics grDevices utils
datasets methods base
other attached packages:
[1] ggplot2_0.8.7 digest_0.4.1 reshape_0.8.3 plyr_0.1.9
proto_0.3-8 gridExtra_0.5 lattice_0.17-26 gtools_2.6.1
More information about the R-help
mailing list