[R] creating rainbow gradients

stephen sefick ssefick at gmail.com
Wed Sep 17 23:05:48 CEST 2008


plot(1:20, col=rainbow(20))

On Wed, Sep 17, 2008 at 4:58 PM, Gillian Silver <haettulegur at gmail.com> 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.)
>
> Could someone please help?
>
> Thanks!
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

	-K. Mullis



More information about the R-help mailing list