[R] Multiple palettes on single plot don't get rendered when I use dev.copy2pdf

Andrew Crane-Droesch andrewcd at gmail.com
Wed Dec 12 01:17:50 CET 2012


Hi All,

I'm having trouble with the colors on my screen getting translated to 
the colors in the outputted .pdf document.

Here is a caricature of my problem:

par(mfrow=c(1,1))
x1 = rnorm(1000)
x2 = rnorm(1000)+10
y1 = rnorm(1000)+10
y2 = rnorm(1000)+10
palette(rainbow(6))
plot(x=x1,y=y1,col=y1,xlim=c(-10,20))

palette(heat.colors(6))
points(x=x2,y=y2,col=y2)

     dev.copy2pdf(file = "broke.pdf", height = 8, width = 8)

I plot the two normal blobs in two different color palettes, and it 
looks fine on the screen.  I go to look at the PDF, and they are BOTH in 
heat map.

How would I render both palettes on the pdf?

Many thanks,
Andrew



More information about the R-help mailing list