Skip to content

ggplot 2 - editing in the "panel_1_1" viewport

3 messages · Pedro Barros, Paul Murrell

#
Hi
Pedro Barros wrote:
Being able to divine the names of grobs (and viewports) is dependent on
the system being used to name the grobs/viewports.  One approach, taken
in lattice for viewports, is to provide a function, e.g.,
trellis.vpname(), that builds a name from salient bits of information,
e.g., panel numbers.  Another important source of information is
documentation of the naming scheme, e.g., for ggplot2, Hadley's
http://had.co.nz/ggplot2/book/grid.pdf

Paul

  
    
#
Hi Paul,
Thanks for the tips. I am using ggplot indeed, but I am trying to "drill
down", and extract several grobs, most of which are gTrees or frames. Until
now, I have more or less managed, but I am having difficulties because I
would like to get at the gTrees that are in each cell of a frame. From a
grid.ls() printout, I managed to discover that these are cellGrobs, but I
cannot find any documentation for these.
So, the more straightforward question would be "If I have a frameGrob, with
several children (in different levels), how can I get the grob that is in
row 2, column 4?". I assume there is a way, but I could not find out how...

Thanks a lot for the great package, BTW!
Pedro
Paul Murrell wrote:

  
    
8 days later
#
Hi
Pedro Barros wrote:
There is no "system" to the naming of cellGrobs because cells can occupy
any subset of the cells of a frame, including overlapping each other and
more than one cellGrob in the same cell (i.e., I could think of no
simple, completely general naming scheme).  However, all is hopefully
not lost because you can hopefully apply a naming scheme to the gTrees
that you are placing within the cells and you can make use of that (?).
 You may need to make use of the 'grep' argument of grid.get() et al to
specify a gPath through a cellGrob that you do not know the *exact* name
for.

Paul