Re: [R] function in order to plot the same graph to postscript and pdf

From: Ronny Klein <>
Date: Thu 10 Mar 2005 - 19:32:55 EST

> I guess you would want eval(MYPLOT) there?
> But the function above works if you say
> plot.both(myplot = expression(plot(x)), filename = "foo")
> and that is what I said above: set myplot = expression(plot(x)).
> Z

My syntax in the example was a little bit messed, sorry for that.

However Gabor Grothendieck's reply has brought me to the solution. The following function does the job right:

print.both <- function(myplot, filename){

     pdf(file=paste(filename, ".pdf", sep=""))
     postscript(file=paste(filename, ".eps", sep=""))

The dev.control(displaylist="enable") is necessary here because only then R does record the plot and dev.copy can be used.

So, thank you all for your help.

Ronny mailing list PLEASE do read the posting guide! Received on Thu Mar 10 19:53:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:42 EST