[R] filled.contour colors

Jim Lemon jim at bitwrit.com.au
Mon Dec 27 12:57:00 CET 2010


On 12/27/2010 02:21 PM, randhindi wrote:
>
> Hi,
>
> I am trying to set the color scale in filled.contour based on a specific
> value instead of a relative position.
> Specifically, I want the values below 0 to be in a gradient of green, and
> those above 0 to be red. 0 would be white.
>
> I tried:
>
> posZero = abs(min(z)) / (abs(min(z)) + max(z));
> filed.contour(..., col = designer.colors(n=30, col=c("green", "white",
> "red"), x=c(0, posZero, 1)))
>
> but it does not center the white on the zero.

Hi Rand,
Have a look at the examples for color2D.matplot in the plotrix package. 
These show how to use color.scale to produce a set of colors like you 
describe above.

Jim



More information about the R-help mailing list