[R] Persp and color and adding a color vector

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Sep 16 16:07:44 CEST 2003

Mark Marques wrote:

> Followin Prof. Uwes 

Who's that? If you mean me, I am not a Professor ...

 > idea and after checking up some docs I was able to
> build a color vector with the correct colors and then "call" it from
> using persp col = option ...
> Nevertheless I still have a small problem...
> using something like :
> colorvect <- rainbow(length(mat3),start=0.1,end=0.8)

Attention: ?persp tells you there are (nx-1)(ny-1) facets given you have 
a matrix of dimension nx x ny.
Additionally, this was not my idea, at least you have to select the 
colors by height, if I understood your question correctly.

> persp(mat3,col=colorvect, box= FALSE, theta=30)
> works something like I need...
> But ...
> if I try to visualize a specific part like mat3[1:900,2:78] ...
> persp(mat3[1:900,2:78,col=colorvect, box= FALSE, theta=30)
> What I get is bleach result with only part of the colors...

What about writing a little function along the lines of

  foo <- function(M){
	colvect <- ...(M)...
	persp(M, .....)
and calling it with

> I know that I were specting this but how can I avoid it with making
> the colorvect vector each time I call persp ?

As already mentioned, generate some colors and then take one color for a 
certain range of values of your matrix.

Anyway, wireframe() in package lattice might have some features that are 
much more convenient to perform your task, as mentioned by someone else 
(too lazy to look into the archives).

Uwe Ligges

> The other idea is making an equivalent matrix with each cell with the
> color info...
> but how can I automate that kind of procedure ?
> THanks
> Mark Marques
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

More information about the R-help mailing list