Skip to content

grid.edit() for ggplot2

2 messages · Baptiste Auguie, Gabor Grothendieck

#
Dear all,


I'm trying to access and modify grobs in a ggplot2 plot. The basic  
idea for raw Grid objects I understand from Paul Murrell's R graphics  
book, or this page of examples,

http://www.stat.auckland.ac.nz/~paul/grid/copygrob/copygrobs.R

However I can't figure out how to apply this to a ggplot (basically I  
don't know how to write a syntactically correct gPath),


p <- # minimal example
qplot(0,0)+ annotate("text",0,0,label="test")

g <- # store the plot as a grob
ggplotGrob(p)

# structure of the grob
grid.ls(g) # rather large!

# find a particular grob in the gTree
getGrob(g,"texts", grep = T)


# next step, modify, say, the colour of these grobs
grid.edit() # what do I put in here?


Thanks for any piece of advice,

baptiste
#
If you enter the code in this post first:
https://stat.ethz.ch/pipermail/r-help/2009-May/198791.html

then this post shows an example of how to do it with lattice:
https://stat.ethz.ch/pipermail/r-help/2009-May/199146.html

but I think there is a bug in grid since similar code does
not seem to work with your example of grid graphics
generated by ggplot2.
On Sun, May 31, 2009 at 9:01 AM, baptiste auguie <ba208 at exeter.ac.uk> wrote: