[R] producing colour .eps output

David Winsemius dwinsemius at comcast.net
Sun Oct 12 18:27:03 CEST 2008


On Oct 11, 2008, at 1:04 PM, Prof Brian Ripley wrote:

> I don't see anywhere you asked for colour, and postscript() is  
> regarded as a 'print device' so the default is monochrome.
>
> See ?trellis.device and the discussion of themes there: AFAICS you  
> want to set a colour theme.

I was at what seemed like a dead end after reading the help pages and  
chapter 7 of Sarkar's lattice text that had examples of color output  
but I saw no example code that produced such. Proceeding as I imagined  
the help pages to be directing me ....

 > lattice.options(default.theme = "col.whitebg")

 > postscript("figs%03d.eps", width = 6.0, height = 6.0,
+            horizontal = FALSE, onefile = FALSE, paper = "special",  
colormodel = "rgb")
# tried adding color = TRUE in the postscript  call but it threw an  
error so I then added it to the plot function.
 > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width |  
Species,
+        data = iris, scales = "free", layout = c(2, 2),
+        auto.key = list(x = .6, y = .7, corner = c(0, 0), color=TRUE))
 > dev.off()
postscript
          2

### black and white output in the file

Then I tried:

 > trellis.device(device="postscript", color = TRUE)
 > postscript("figs%03d.eps", width = 6.0, height = 6.0,
+            horizontal = FALSE, onefile = FALSE, paper = "special",  
colormodel = "rgb")
 > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width |  
Species,
+        data = iris, scales = "free", layout = c(2, 2),
+        auto.key = list(x = .6, y = .7, corner = c(0, 0),  
color=TRUE))    # color= probably not needed since it did not have  
desired effect
 > dev.off()
postscript
          2

With the desired results. I had thought that the plot function would  
be passing the color= parameter to the output device, but apparently  
not.



>
>
> On Sat, 11 Oct 2008, RICHARD PITMAN wrote:
>
>> I am using the following code to produce a graphic:
>>
>> library(lattice)
>> postscript("figs%03d.eps", width = 6.0, height = 6.0,
>>            horizontal = FALSE, onefile = FALSE, paper = "special")
>> xyplot(cases~yr|agrp*sex,data=data[tse==0 & expgrp==1,],
>>      groups=source, pch=".", type="l",
>>        main="Exposure group 1, time since entry 0")
>>
>> The resulting figure is in black and white and I can not seem to  
>> find a way to get colour output.
>>
>> Any pointers gratefully received.
>>
>> TIA
>>
>> Richard
>
> -- 
> 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______________________________________________
> R-help at 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.



More information about the R-help mailing list