Removing "layers"

13 views
Skip to first unread message

Brandon Farr

unread,
Mar 27, 2009, 1:02:43 PM3/27/09
to ggplot2
I'm curious if one is able to remove layers from a ggplot object. My
case is as follows. I have done an awful lot of automated plot
creation, and have saved all ggplot objects to RData files. Later on,
I can revisit the plots and utilize the fact that the object is self
contained. My question is, can I remove a layer? Specifically in the
automated process I used levels of factor "a" to specify "linetype",
but would like to go back and facet based on factor "a" and have a
single "linetype". Is this possible?

Thanks,
Brandon

hadley wickham

unread,
Mar 27, 2009, 1:18:28 PM3/27/09
to Brandon Farr, ggplot2
Hi Brandon,

It's not really possible (although you can dig around in p$layers and
do it yourself) - I have thought about it, but haven't figured out the
right interface yet.

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

Brandon Farr

unread,
Mar 27, 2009, 1:23:54 PM3/27/09
to ggplot2
Hadley,

As always, thanks for the quick reply. As often happens, after posting
question digging around becomes much more fruitful. I determined that
if I call:

p$layers[[i]] <- NULL

I can remove the un-needed layer, and can then start to rebuild. Not a
process I would want to automate, as it isn't clear without inspection
what each layer does, but this works for custom charting.

Thanks for such a great package,
Brandon

On Mar 27, 1:18 pm, hadley wickham <h.wick...@gmail.com> wrote:
> Hi Brandon,
>
> It's not really possible (although you can dig around in p$layers and
> do it yourself) - I have thought about it, but haven't figured out the
> right interface yet.
>
> Hadley
>
Reply all
Reply to author
Forward
0 new messages