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 - 01:11:17 EST

On Wed, 9 Mar 2005 14:57:27 +0100 Ronny Klein wrote:

> Hi,
>
> I've written a function in order to plot the same graph in a postcript
> and in a pdf file. Unfortunately, the second graph is always empty,
> i.e.:
>
> plot.both <- function{myplot, filename}{
> pdf(file=paste(filename, ".pdf", sep=""))
> myplot
> dev.off()
> postscript(file=paste(filename, ".eps", sep=""))
> myplot
> dev.off()
> }
>
> yields in a correct pdf but an empty eps file. However something like
> this:
>
> plot.both <- function{myplot1, myplot2, filename}{
> pdf(file=paste(filename, ".pdf", sep=""))
> myplot1
> dev.off()
> postscript(file=paste(filename, ".eps", sep=""))
> myplot2
> dev.off()
> }
>
> yields the expected results even if myplot1 and myplot2 are identical.

What are the myplot objects? Expressions or graphical objects that are printed?

In any case, a good recommendation for this kind of stuff is to look at Sweave() in the utils package. I guess you're writing your thesis in LaTeX...and Sweave is a great possibility to mix LaTeX code and R code which for example generates both pdf and eps graphics. Z

> Does somebody know, how I can implement the desired (first) function?
>
> Ronny
>
> PS: My system is: Linux Debian Unstable and R-Version: 2.0.1.
>
> ______________________________________________
> 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
>



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 01:17:46 2005

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