[R] Help with color.scale {plotrix}

Jim Lemon drjimlemon at gmail.com
Fri Oct 9 13:24:18 CEST 2015


Hi Kumar,
The color.scale function translates numeric values into one or more
intervals of color by a linear transformation into the numeric values that
specify colors. One of three color spaces (rgb, hcl and hsv) can be
specified, and the endpoints can be specified as "extremes=c(<minimum
color>,<maximum color>" or as three vectors of numbers. By default, the RGB
color space is used, so:

# starts at RGB #FF0000 and finishes at RGB #FFFF00
red to yellow - extremes=c("red","yellow") OR cs1=c(1,1),cs2=(c(0,1),cs3=0
# starts at RGB #FFFF00 and finishes at RGB #00FF00
yellow to green - extremes=c("yellow","green") OR
cs1=c(1,0),cs2=(c(1,1),cs3=0

Obviously the shades of colors that you want may differ from the above, so
you have to play with the values to get the ones you want. In many cases,
you will have to specify more than two numbers for the color specs to get
the "in between" colors right, especially if the span of the colors is
large.

Jim

On Fri, Oct 9, 2015 at 4:15 PM, Kumar Mainali <kpmainali at gmail.com> wrote:

> Hi Jim and others:
>
> I needed color code for some color gradients in color.scale function. I
> found that the following translates to green to yellow to
> red: c(0,1,1),c(1,1,0),0. How does this string translate to the color
> gradient? I would like to know the gradient code for red to yellow, yellow
> to green and other ranges.
>
> Thanks,
> Kumar Mainali
>
> Postdoctoral Associate
> Department of Biology
> University of Maryland, College Park
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list