Paul E Johnson
2003-Jun-05 20:04 UTC
[R] dev.copy2eps: Why did the colors come into my postscript output?
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. -- Paul E. Johnson email: pauljohn at ku.edu Dept. of Political Science http://lark.cc.ku.edu/~pauljohn 1541 Lilac Lane, Rm 504 University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66044-3177 FAX: (785) 864-5700
Prof Brian Ripley
2003-Jun-05 20:59 UTC
[R] dev.copy2eps: Why did the colors come into my postscript output?
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