Hi
> I am working with the persp command. I want to change to color of the
facets> according
> to their z-value. The colors seems to be transposed, i.e. the color of a
facet A> seems
> to be used for a facet B which is a (defined?) way off....
>
> An example:
>
> nx <- 21
> ny <- 21
> x <- seq(-1, 1, length = nx)
> y <- seq(-1, 1, length = ny)
> z <- outer(x, y, function(x,y) x^2 + y^2)
> hgt <- z / max(z)
> persp(x, y, z, col = gray(1 - hgt), theta = 70, phi = 40, expand = 0.4)
>
> Now the z-value should define the color, but the color pattern seems to be
> moved.
I don't think this is a bug -- I think the problem is that the surface
produced for the z of dimension 21x21 has only 20x20 facets. For example,
the following is not a solution, but it shows that a 20x20 colour matrix
produces the expected result ...
persp(x, y, z, col = gray(hgt[1:20,1:20]), theta = 0, phi = 40, expand 0.4)
... now, what you really want I guess is to calculate hgt to be some
interpolation of the four z values at the four corners of each face. I am
due somewhere so this calculation is left as an exercise ...
Paul
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._