[R] Colours in Lattice

From: Lorenzo Isella <lorenzo.isella_at_gmail.com>
Date: Sun 30 Jul 2006 - 07:19:41 EST

Dear All,

I am practicing with the image and wireframe (the latter in the lattice package) plotting tools.
I am a bit puzzled by the colors I observe in some test plots I have been generating.
Consider:

rm(list=ls())
library(lattice)

x <- seq(-2*pi, 2*pi, len = 100)
y <- seq(-2*pi, 2*pi, len = 100)
g <- expand.grid(x = x, y = y)

mylen<-length(x)

g$z <- exp(-(g$x^2 + g$y^2))+exp(-((g$x-2)^2 + (g$y-2)^2))

pdf("my-first-lattice-figure.pdf")
print(wireframe(z ~ x * y, g, drape = TRUE,shade=TRUE,scales = list(arrows = FALSE),pretty=FALSE, aspect = c(1,1), colorkey = TRUE ,zoom=0.8, zlab = list("my radial function",rot = 90),distance=0.0,perspective=TRUE,screen = list(z = 150, x = -55,y= 0),ylim=range(c(-2*pi,2*pi)),xlim=range(c(-2*pi,2*pi)),zlim=range(c(0,1)))) dev.off()

Now, I should have two peaks corresponding to values slightly above 1 which should be cyan, whereas I see a different color. Furthermore, the "floor" of the function should correspond to about zero, so I would expect it to be light purple rather than dark red. Am I making any mistake with the options in the plotting? I suppose it all has to do with the shade argument, but using shade=FALSE leads to a very ugly-looking plot.
Is it possible to overlap another function to the previous one? I am thinking about something like the "lines" command when I use "plot". Finally, when I create a plot using "image", is there a way to have a legenda of the values corresponding to each color (like the "colorkey" argument in wireframe)?
Kind Regards

Lorenzo



R-help@stat.math.ethz.ch 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. Received on Sun Jul 30 07:28:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 30 Jul 2006 - 08:17:05 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.