Re: [R] viewing Postscript file

From: Marc Schwartz <MSchwartz_at_MedAnalytics.com>
Date: Fri 23 Jul 2004 - 09:44:02 EST

On Thu, 2004-07-22 at 16:50, Bickel, David wrote:
> Is there any R function that can display a Postscript file that is
> already in the working directory? For example, if 'graph.ps' is such a
> file, I'd like to type something like this:
> > plot.postscript.file(file = 'graph.ps')
>
> If no such function exists, I'd be interested in a way to use existing
> R functions to do this under UNIX or Windows, preferably without a
> system call to GhostView (gv).
>
> Thanks,
> David

I am not entirely sure what your expectations are here.

As you probably know, Postscript files (like PDF files) are text files that describe how to draw an image. It requires a Postscript interpreter (typically Ghostscript) to read the contents of the PS file and then something like GSview (or gv or ggv or ...) as a front end to render the image.

It is illusory, but you could create a R wrapper function and call it plot.postcript.file():

plot.postscript.file <- function(file = "Rplots.ps") {
  # define viewer for UNIX/LINUX or Windows   viewer <- ifelse(.Platform$OS.type == "unix", "gv", "GSview")    

  system(paste(viewer, file, sep = " ")) }

So:

postscript("graph.ps")
barplot(1:5)
dev.off()
plot.postscript.file("graph.ps")

HTH, Marc Schwartz



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 23 09:52:54 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:11 EST