As daft as it may sound, I'm trying to clip a ggplot2 to a particular
viewport without success. For example,
p = qplot(1:10)
g = ggplotGrob(p)
grid.clip(x = 0.3, width = 0.1)
grid.circle(gp=gpar(fill="red"))
grid.newpage()
grid.clip(x = 0.3, width = 0.1)
grid.draw(g)
Is it currently impossible?
I thought it'd be handy to illustrate specific theme settings.
Best,
baptiste
From the documentation of clipGrob:
Pushing or popping a viewport _always_ overrides the clip region
set by a clip grob, regardless of whether that viewport explicitly
enforces a clipping region.
And ggplot2 uses lots of viewports, so I don't think clipGrob is the
way to enforce clipping. Instead, I think you want to create a new
viewport and draw the ggplot2 grob inside of that.
Hadley
Good point! That explain why lattice behaves similarly.
> And ggplot2 uses lots of viewports, so I don't think clipGrob is the
> way to enforce clipping. Instead, I think you want to create a new
> viewport and draw the ggplot2 grob inside of that.
>
But in that case the ggplot2 grob will scale rather than be clipped,
p = qplot(1:10)
g = ggplotGrob(p)
pushViewport(viewport(width=0.2))
grid.draw(g)
Am I missing something?
Thanks,
baptiste
> Hadley
>
>
> --
> http://had.co.nz/
Oh true. Hmmm, maybe ask Paul?
Hadley