[R] 3d plot with different levels done in different colors

Tamas Papp tpapp at axelero.hu
Fri Jul 11 17:26:02 CEST 2003


I would like a 3d plot of a matrix such that individual trapezoids
that make up the surface are colored according to the z-value of that
point (or preferably the midpoint of its four corners, or something
similar). MS Excel has something like that.

I know that persp can have an nx by ny matrix its "col" argument, I
just don't know how to generate that matrix. To calculate the midpoint
of the tiles for the matrix z, I could use something like

zz <- (z[-1,-1] + z[-1,-nrow(z)] + z[-ncol(z),-1] + z[-ncol(z),-nrow(z)])/4

but I don't know how to assign a color to that value. For example if I
have

boundaries <- c(0, .5, 1, 1.5)

and 

colors <- c("red", "green", "blue")

I am looking for a function that assigns red to the elements of zz
between 0 and .5, etc. Alternative solutions are welcome, maybe
somebody has already wrote a library that does the whole thing neatly.

Thanks,

Tamas

-- 
Tamás K. Papp
E-mail: tpapp at axelero.hu (preferred, especially for large messages)
        tpapp at westel900.net
Please try to send only (latin-2) plain text, not HTML or other garbage.




More information about the R-help mailing list