Skip to content

dev.copy2eps: Why did the colors come into my postscript output?

2 messages · Paul Johnson, Brian Ripley

#
On a RedHat 7.3 system with R-1.6.1, I did this

 > x11(width=3.5,height=4,colortype="gray")

Then plotted (with matplot) a nice looking no-color graph on the screen, 
then I did this:

 > dev.copy2eps(file="test.eps",height=4,width=3.5)

I was surprised that the output in the eps file included the colored 
lines from the plot, even though the screen device was set to "gray" and 
on screen I did not see colors.

I put some of the eps files up here, so you can see what I mean:

http://lark.cc.ku.edu/~pauljohn/R/epsfiles

And if you don't have an eps viewer handy, I made png versions, since 
all browsers seem to show them.

http://lark.cc.ku.edu/~pauljohn/R/pngfiles/

The docs indicate that the x11 device is being copied, but I rather 
think that a plot object that exists "behind" the x11 device is being 
saved.?

I have since learned that I can put col=c("black") into the matplot 
command to make sure no colors are used, and that works the way I 
expect.  But I was curious about this behavior in dev.copy2eps.
#
On Thu, 5 Jun 2003, Paul E Johnson wrote:

            
[...]
You did a coloured plot and displayed it on grey-scale device. The
plotting internals has no idea (nor does it care) how the plot was
rendered.  (Nor does it know if you have a colour screen or not.)  
dev.copy() just replays the plot on a new device: a postscript device if
the dev.copy2eps wrapper is used.

You only see the colours in the eps file if you display that on a colour 
device, BTW, and most postscript renders are not.
No mystery: it just works as it is documented.  Please read the nuances of
the help page.