Skip to content

creating rainbow gradients

9 messages · stephen sefick, Gillian Silver, Jorge Ivan Velez +4 more

#
plot(1:20, col=rainbow(20))
On Wed, Sep 17, 2008 at 4:58 PM, Gillian Silver <haettulegur at gmail.com> wrote:

  
    
#
On Wed, Sep 17, 2008 at 3:11 PM, Gillian Silver <haettulegur at gmail.com> wrote:
Do you mean something like the following?

z <- rnorm(1000, sd = sqrt(2))
plot(z, col = rainbow(length(z), end = 5/6)[rank(z)], pch = 19)
#
On second thought, this is more likely to be what you're looking for...

library(rgl)
x <- rnorm(1000)
y <- rnorm(1000)
z <- x + y
plot3d(x, y, z, col = rainbow(1000, end = 5/6)[rank(z)], size = 3)


On Wed, Sep 17, 2008 at 4:06 PM, Kingsford Jones
<kingsfordjones at gmail.com> wrote:
#
On Wed, Sep 17, 2008 at 3:58 PM, Gillian Silver <haettulegur at gmail.com> wrote:
Why would you want to?  See
http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_c87
 for some better alternatives.

Hadley
#
On 17/09/2008 4:58 PM, Gillian Silver wrote:
Others have pointed you to the rainbow() function; you should also look 
at colorRamp, in case you want to construct your own colour sequence.

Duncan Murdoch
#
Gillian Silver wrote:
Hi Gillian,
Try:

my.rainbow<-color.scale(x,c(1,1,0,0),c(0,1,1,0),c(0,0,0,1))

The "extremes" argument takes precedence over your color ranges

Jim