[R] lattice grob

Felix Andrews felix at nfrac.org
Mon Mar 22 00:18:16 CET 2010


What's wrong with using grid.grabExpr?

p1 <- xyplot(1:10 ~ 1:10)
g1 <- grid.grabExpr(print(p1))

I can imagine there would be potential problems to do with the
plot-time aspect and layout calculations...



On 19 March 2010 21:51, baptiste auguie <baptiste.auguie at googlemail.com> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/



More information about the R-help mailing list