A few solutions are provided here : http://stackoverflow.com/questions/3712402/r-how-to-change-lattice-levelplot-color-theme. However, I somehow had troubles using the PDF device in R: the output file was blank. Using the PNG device works fine, but I'd rather have PDF files included in my thesis as I'm working with LaTeX.
The simplest solution was to output a PDF with the basic Lattice code then to use the gs command in bash to convert to grayscale. Job done!
1. Output the plot :
2. Convert to grayscale using gs in bash :pdf(file='myfile.pdf')
## my lattice plot code
dev.off()
$ gs -sOutputFile=output.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibilityLevel=1.4 myfile.pdf < /dev/null
The result simply looks like this :
Saving a lattice plot with grayscale directly in R can be a bit too tricky, to me this is by far the fastest solution around.

No comments:
Post a Comment