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

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jun 5 22:59:40 CEST 2003


On Thu, 5 Jun 2003, Paul E Johnson wrote:

> 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.

[...]

> 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.?

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.

> 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.

No mystery: it just works as it is documented.  Please read the nuances of
the help page.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list