[R] Print grid/ggplot to a metafile

Dieter Menne dieter.menne at menne-biomed.de
Fri Jun 29 21:48:25 CEST 2007


Dear UseRs called Hadley, or Paul,

I am trying to print an edited ggplot2/grid graphics to a metafile. With the
commented line below it works, but when I edit the plot by uncommenting the
line, it fails, because it's illegal to have 2 graphics in a metafile. It
works with pdf, but even then I get two plots, which is a nuisance.

I found a workaround by using windows(); savePlot, but it only works in
interactive mode, not when called with something like (Windows)

rterm --no-save < printit.r

Any ideas?

Dieter

#------
library(ggplot2)
win.metafile(file="bar.emf")
mtcars$cyls = factor(mtcars$cyl,
  labels=c("four\ncylinders","six\ncylinders","eight\ncylinders"))
ggplot(mtcars, aes(x=cyls)) + geom_bar()
#grid.gedit("xaxis::labels::label.text",just=c("center","center"))
dev.off()



More information about the R-help mailing list