[R] Colours in Lattice
Lorenzo Isella
lorenzo.isella at gmail.com
Sat Jul 29 23:19:41 CEST 2006
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
More information about the R-help
mailing list