[R] navigating ggplot viewports

hadley wickham h.wickham at gmail.com
Tue Jan 15 19:33:47 CET 2008


Hi Felix,

I'm a bit stumped too - it's been a while since I've played around
with viewports in ggplot.  I have a feeling that this might be due to
an old bug in grid that I thought had been fixed - you can't
downViewport to a viewport underneath a frame grob.  I've cc'd Paul in
the hope that he might have a suggestion.

Hadley

2008/1/14 Felix Andrews <felix at nfrac.org>:
> list(...)
>
> I can not get at the grid viewports in a ggplot2 plot.
> I know there is supposed to be a viewport called "panel_1_1" but
> downViewport() can't find it. Has the viewport been popped?
> I had a quick look at the functions involved (eg ggplot_plot)
> but there is no obvious problem there.
>
> > library(ggplot2)
> > qplot(1:10, 1:10)
> > current.viewport()
> viewport[ROOT]
> > downViewport("panel_1_1")
> Error in downViewport.vpPath(vpPathDirect(name), strict, recording =
> recording) :
>   Viewport 'panel_1_1' was not found
> > current.vpTree()
> viewport[ROOT]->(viewport[GRID.VP.1])
> > grid.ls(viewports=T, grob=F)
> ROOT
>   GRID.VP.2
>     1
>   GRID.VP.3
>     layout
>       strip_h_1_1
>         1
>       strip_v_1_1
>         1
>       axis_h_1_1
>         1
>       axis_v_1_1
>         1
>       panel_1_1
>         2
>     layout
>       panel_1_1
>         2
>     layout
>       axis_v_1_1
>         left_axis
>           labels
>             1
>           ticks
>             2
>         left_axis
>           ticks
>             2
>         left_axis
>           labels
>             2
>         2
>     layout
>       axis_h_1_1
>         bottom_axis
>           labels
>             1
>           ticks
>             2
>         bottom_axis
>           ticks
>             2
>         bottom_axis
>           labels
>             2
>         2
>     layout
>       panel_1_1
>         2
>     layout
>       panel_1_1
>         2
>     layout
>       panel_1_1
>         2
>     1
>   GRID.VP.4
>     1
>   GRID.VP.5
>     1
>   GRID.VP.6
>     1
>
> > sessionInfo()
> R version 2.6.1 (2007-11-26)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252
>
> attached base packages:
> [1] splines   grid      stats     graphics  grDevices utils     datasets
> [8] methods   base
>
> other attached packages:
> [1] ggplot2_0.5.7      colorspace_0.95    RColorBrewer_1.0-2 MASS_7.2-38
> [5] proto_0.3-8        reshape_0.8.0
>
> loaded via a namespace (and not attached):
> [1] tools_2.6.1
>
>
> --
> Felix Andrews / 安福立
> PhD candidate
> Integrated Catchment Assessment and Management Centre
> The Fenner School of Environment and Society
> The Australian National University (Building 48A), ACT 0200
> Beijing Bag, Locked Bag 40, Kingston ACT 2604
> http://www.neurofractal.org/felix/
> 3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8
>
>
> ______________________________________________
> 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.
>
>



-- 
http://had.co.nz/




More information about the R-help mailing list