Main · Black and White in R

This page was last modified on 26 May 2007, at 22:38 NZST

Main.BlackAndWhiteInR History

Hide minor edits - Show changes to markup

26 May 2007, at 22:38 NZST by Luis -
Changed line 6 from:

(:source :)[@

to:

(:source lang=R:)[@

Changed line 8 from:
      width = 11.7, height = 8.26, pointsize = 9)
to:
     width = 11.7, height = 8.26, pointsize = 9)
25 May 2007, at 23:25 NZST by Luis -
Changed lines 22-24 from:

which works perfectly.

to:

which works perfectly.

Keywords: , .

17 May 2007, at 16:59 NZST by Luis -
Changed lines 7-8 from:

pdf(‘~/Documents/Research/2007/Algae/temp05degrees.pdf’)

to:

pdf(‘~/Documents/Research/2007/Algae/temp05degrees.pdf’,

      width = 11.7, height = 8.26, pointsize = 9)
17 May 2007, at 15:34 NZST by Luis -
Added lines 1-21:

(:Blog:1:) I was creating some trellis plots using R for a student, who wanted everything in black and white. I was playing with the xyplot command, setting options, fixing all the little details (even discovering some data issues in the process). Then, I decided to save them as PDF, when I discovered that, duh!, pdf() always saves everything as colour. Before thinking on saving the files I was using trellis.device(color = FALSE), but it did not make a difference for exporting as PDF.

Looking in the R email lists I found that one has to use trellis.device() after calling pdf() and force it to avoid creating a new canvas. Something like this:

(:source :)
pdf('~/Documents/Research/2007/Algae/temp05degrees.pdf')
trellis.device(new = FALSE, color = FALSE)

# and then the graph
xyplot(percent ~ time | temp:light.level:humidity, 
       group = tray, 
       type = 'b', 
       data = rocks[rocks$temp == 5,],
       xlab = 'Exposure [hours]', 
       ylab = 'Percentage live [%]',
       layout = c(4,2))
dev.off()

which works perfectly.