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

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Thu 10 Mar 2005 - 05:35:13 EST

On Wed, 9 Mar 2005 18:21:41 +0100 Ronny Klein wrote:

> > > The myplot is something like this:
> > >
> > > plot(x)
> > > text(foo)
> >
> > Aha, I was surprised that this worked for one of the two plots.
> > You could pass myplot as an expression, e.g. myplot =
> > expression(plot(x)), and then eval() that in the body of
> > plot.both().
>
> I've followed your advice

Not quite...

> and changed my function to something like this:
>
> plot.both <- function{myplot, filename}{
> MYPLOT <- expression(myplot)
> pdf(file=paste(filename, ".pdf", sep=""))
> eval(myplot)
> dev.off()
> postscript(file=paste(filename, ".eps", sep=""))
> eval(myplot)
> dev.off()
> }

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

> However the result is the same: the first one is actually printed but
> the second plot is empty.
>
> Ronny
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Mar 10 05:52:49 2005

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