[R] dev.print and X11(canvas = "black")

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Mar 2 08:15:36 CET 2004


On Mon, 1 Mar 2004 jhallman at frb.gov wrote:

> In Splus, I often use graphics windows with a black background and white
> foreground.  The S print.graph() function sends the current plot to my
> printer but with a white background and black foreground.  I'd like to

S (and S-PLUS) only has a few colour numbers, and you can change their 
interpretation on the screen graphics devices after plotting.  R does plot 
in colours rather than numbers.

> be able to do something similar in R, but can't figure out how.  I've
> tried various permutations of dev.copy() and dev.print(), but it seems
> that the foreground color is fixed when the original plot is drawn, and
> dev.copy always redraws it with that color.  So even though I can get my
> postscript output with a white background, things that were drawn white on the
> dark background of my X11 device are still drawn white when dev.copy'd
> to a postscript device.  Since the postscript has a white background,
> that means the white foreground stuff doesn't show up.
> 
> Is there a way to handle this?  Or do I just have to give up on ever
> using a dark canvas in X11() if I ever want to print the result?

There are many ways to print the result, and re-running the plot commands 
after switching to a postscript() device is one of the best.  This would 
work for you if you only ever use colour numbers and switch the palette
(and par("fg")).

> Please reply directly.
> 
> Jeff

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