[R] creating rainbow gradients
Jim Lemon
jim at bitwrit.com.au
Thu Sep 18 14:28:26 CEST 2008
Gillian Silver wrote:
> Hi, how can I create a rainbow gradient in R? For example, let's say I have
> a plot of y = x...and I want the plot to go from red -> orange -> yellow ->
> green -> blue -> etc.
> Right now, I know how to do something like go from red to blue, using the
> plotrix library:
>
> library(plotrix)
> redToBlue <-
> color.scale(x,redrange=c(0,1),greenrange=c(0,1),bluerange=c(0,1),extremes=c("red","blue"))
> plot(x, y, col=redToBlue)
>
> But I can't figure out how to make the colors a rainbow. (I don't understand
> how the redrange, greenrange, and bluerange parameters in color.scale work.)
>
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
More information about the R-help
mailing list