Error: could not find function "geditGrob"

635 views
Skip to first unread message

Taiyun Wei

unread,
Mar 21, 2012, 7:52:05 AM3/21/12
to ggp...@googlegroups.com
Dear all,

I run a example in the book ggplot2: Elegant Graphics for Data Analysis (page 201-202, appendix C.4),however I found a error:

> p <- qplot(wt, mpg, data = mtcars, colour = cyl)
> grob <- ggplotGrob(p)
> grob <- geditGrob(grob, gPath("strip", "label"), 
+ gp = gpar(fontface = "bold"))
Error: could not find function "geditGrob"
> grid.newpage()
> grid.draw(grob)


Is there a function similar to geditGrob() in ggplot2 0.9.0? 

Thanks~

--
Regards,
Taiyun
--
Taiyun Wei <weit...@gmail.com>
Homepage: http://taiyun.cos.name
Phone: +86-15201142716
Renmin University of China

baptiste auguie

unread,
Mar 21, 2012, 3:00:19 PM3/21/12
to Taiyun Wei, ggp...@googlegroups.com
Hi,

You need to load the grid package.

HTH,

b.

> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Tengfei Yin

unread,
Mar 21, 2012, 3:43:18 PM3/21/12
to baptiste auguie, Taiyun Wei, ggp...@googlegroups.com
Hi Baptiste and Taiyun, 

...  "editGrob" is function from grid, but is geditGrob an dropped function from ggplot2?  I cannot find it anymore...

following code works for me

library(ggplot2)
p <- qplot(wt, mpg, data = mtcars, colour = cyl)
p
grid.ls(ggplotGrob(p)) # see the guide-box for title name
grid.edit("title-2-2", gp= gpar(fontface = "italic", fontsize = 16))


Tengfei
--
Tengfei Yin
MCDB PhD student
1620 Howe Hall, 2274,
Iowa State University
Ames, IA,50011-2274
Homepage: www.tengfei.name


baptiste auguie

unread,
Mar 21, 2012, 5:40:19 PM3/21/12
to Tengfei Yin, Taiyun Wei, ggp...@googlegroups.com
Hi,

You're right, it was in ggplot2

https://github.com/hadley/ggplot2/commit/1bc4d1e179536e3404418a9589d982c242a40793

you can simply use grid::editGrob instead with grep = TRUE, global = TRUE.

HTH,

baptiste

benjami...@googlemail.com

unread,
Apr 2, 2014, 5:22:51 AM4/2/14
to ggp...@googlegroups.com, Tengfei Yin, Taiyun Wei, baptist...@googlemail.com, h.wi...@gmail.com
Hi everyone,

I try to find ways to assess the grob objects for some time now. I tried to follow appendix C of the ggplot2 book. However, the code snippet in section C.4 ceased to work.

p <- qplot(wt, mpg, data = mtcars, colour = cyl)
grob <- ggplotGrob(p)
grob <- editGrob(grob, gPath("strip", "label"), gp = gpar(fontface = "bold"),
                 grep = TRUE, global = TRUE)

<error--- only gTree objects can be edited>

and if I use

p
grid.ls(ggplotGrob(p))

all I get is  "layout".

My actual problem is described here:

https://groups.google.com/forum/#!topic/ggplot2/iygHrbUNy7w

As indicated in the linked post, I think that either the interfaces of ggplot2 or lattice have changed.
Or is ggplot no longer relying on lattice in the backend?

I need the margins to be nice in an automated way for a package I am currently writing (http://r-forge.r-project.org/projects/lethal/).

Can anyone give me any hints on how to proceed?

All the best,
Benjamin
Reply all
Reply to author
Forward
0 new messages