On Fri, 22 Jul 2011, James Cloos wrote:
Please do note the posting guide: the context you omitted (when
explicitly asked not to) is in the thread starting:
https://stat.ethz.ch/pipermail/r-help/2011-July/284352.html
I suspect that a few s/def/bind def/ on that prologue might improve
things a bit.
No discernable difference on the viewers I tested.
The ps R creates freely switches between the sRGB ABC space and
setgray. That is a good thing; it helps ensure that black will
be just black when sent to a CMYK device. Without that you can
get CMY black from some devices. But it does complicate things.
(CMYK devices often use CMY black rather than K black when the
source is RGB black because it is better when printing contone
images, such as photographs. But it just wastes ink and toner
when printing charts and similar graphics.)
I've not seen a printer driver which does that for many years. But
remember that R's postscript() has origins in the mid-1990s.
R's pdf() is newer (R 1.3.0, 2001) and even by then the optimization
could safely be left to the driver.
The best improvement would be to have R keep track of the last
colorspace and only run the srgb procedure when switching from
DeviceGray, rather than every time it changes the RGB colour.
Actually no, as it can do that rather often. Consider the pairs plots
of the iris data in demo(graphics): that does (1200 times)
switch to red, blue or green
fill circle
switch to black
draw circle outline.
Some viewers are rather slow in running that procedure, and on those
viewers this example is slow.
Workarounds:
1) Use pdf(), where the viewers seem to cache colorspaces.
2) In R-patched, use colormodel="rgb-nogray", which never switches
colorspace ("srgb-nogray" in R-devel).
3) In R-devel, use colormodel="rgb" (rather than "srgb") and give up
the colour accuracy (if your viewer is not already set for sRGB) for
speed.
The SetColor() function in R/src/library/grDevices/src/devPS.c
looks to be the place to do that. The Invalidate() function
and the PostScriptDesc struct there also need to track any
such changes.
Hmm, you seem not to understand how the code works. The postscript
macro /bg switches colour, and the macros /p3 and similar use
different colorspaces during their execution. It isn't just SetColor
as its setting may not be used immediately.
-JimC
--
James Cloos <cl...@jhcloos.com> OpenPGP: 1024D/ED7DAEA6
--
Brian D. Ripley, rip...@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
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.