Re: [R] overdrawing a plot

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Wed, 20 Feb 2008 13:16:10 +0000 (UTC)

Gallego Liberman, Matias <m.gallego <at> isofoton.com> writes:

> When using grid.edit inside a pdf device it applies the changes on a
> second plot, not erasing the first one.
..
> >DF<-data.frame(A=c(1:12),B=c(1:12)*c(rnorm(12,mean=1)),C=2*c(1:12),D=re
> p(c(1:4),each=3))
> >trellis.device(pdf,file='prueba.pdf')
> >ggplot()+geom_line(mapping=aes(x=A,y=B,colour=D),data=DF)
> >grid.edit(gPath('legend'),gp=gpar(fontsize=8),grep=TRUE,redraw=TRUE)
> >dev.off()
>
> produces a two pages pdf document, one with and one without the changes
> inttroduced by grid.edit
...

I had a similar problem, and Paul Murrell sent me a workaround:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/104038.html

"You can capture the ggplot drawing as a grid grob (gTree), edit that (no drawing occurs to this point), and then draw it ..."

Hadley realized that this is a bit awkward, and it could be there is a better solution in the post-christmas revision.

Dieter



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 20 Feb 2008 - 13:20:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 23 Feb 2008 - 18:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive