From rpeng at jhsph.edu  Fri Feb 20 16:30:07 2004
From: rpeng at jhsph.edu (Roger D. Peng)
Date: Fri Feb 20 16:34:40 2004
Subject: [Rd] unexpected postscript output with par(mfg)
Message-ID: <403627FF.70602@jhsph.edu>

Hi, a colleague of mine encountered some unexpected behavior regarding 
the postscript output from R.  It's difficult for me to tell whether 
or not this is an R problem or a ghostview/gv/interpreter problem. 
Just to note, I think it's exactly the same situation reported here:

http://finzi.psych.upenn.edu/R/Rhelp02/archive/25436.html

The following code produces a working plot (no problems, as far as I 
can see):

par(mfrow = c(2,2))
plot.new()
plot(1:10, 1:10, xlab = "", ylab = "")
plot(1:10, 1:10, xlab = "", ylab = "")
plot(1:10, 1:10, xlab = "", ylab = "")
dev.copy2eps(file = "plot1.eps")

However, the following code, which appears on the screen to be 
identical to the above plot, generates an EPS file which ghostview/gv 
displays as blank.

par(mfrow = c(2,2), mfg = c(1,2))
plot(1:10, 1:10, xlab = "", ylab = "")
plot(1:10, 1:10, xlab = "", ylab = "")
plot(1:10, 1:10, xlab = "", ylab = "")
dev.copy2eps(file = "plot2.eps")

If I use postcript() directly instead of dev.copy2eps(), plot1 is 
again fine, and plot2 appears fine when viewed in gv.  However, when 
plot2 is included into a LaTeX file (via \includegraphics), it is 
upside-down and backwards and resized.

Has anyone encountered such behavior before?  When I run a diff on 
plot1.eps and plot2.eps (generated by dev.copy2eps) it looks like 
there is an entire chunk of code in plot1.eps that doesn't exist in 
plot2.eps.

The problem was originally identified on Windows but it happens on 
Linux too.

Any suggestions would be greatly appreciated.

-roger


[Rd] unexpected postscript output with par(mfg)
Roger D. Peng