[R] creating rainbow gradients

Carl Witthoft carl at witthoft.com
Fri Sep 19 05:10:23 CEST 2008

From: Gillian Silver <haettulegur_at_gmail.com>
Date: Wed, 17 Sep 2008 14:11:39 -0700

What would I do if I have something like:

x <- rnorm(1:1000)
y <- rnorm(1:1000)
z <- x + y

and I want the rainbow to increase with z? (i.e., red for lowest z...all 
the way up to the last color in the rainbow for the highest z)


I can't help w/ a 3-d function directly,  but my cute little tool

clplot()  will do exactly that for any pair of x, y vectors.  It's 
available in the latest plotrix  package.

The code is not very complicated, so I'd imagine you could rewrite it to 
handle z=  f(x,y) on your own :-)


More information about the R-help mailing list