Skip to content
Back to formatted view

Raw Message

Message-ID: <1355273297.73275.YahooMailNeo@web142602.mail.bf1.yahoo.com>
Date: 2012-12-12T00:48:17Z
From: arun
Subject: Multiple palettes on single plot don't get rendered when I use dev.copy2pdf
In-Reply-To: <50C7CD2E.8080803@gmail.com>

Hi,
Try this:
?pdf("broke.pdf")
?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.off()
A.K.



----- Original Message -----
From: Andrew Crane-Droesch <andrewcd at gmail.com>
To: R help <r-help at r-project.org>
Cc: 
Sent: Tuesday, December 11, 2012 7:17 PM
Subject: [R] Multiple palettes on single plot don't get rendered when I use dev.copy2pdf

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

______________________________________________
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.