[R] Setting a Red->Yellow->Green Color Transition in Image(...) with yellow corresponding with the Mean Value...
Jason Rupert
jasonkrupert at yahoo.com
Sat Nov 20 14:53:46 CET 2010
In the following example I would like to have the color transition from
Red->yellow->green in the image(...) function, and if possible have the yellow
be set to correspond with the mean value (for the below 75).
I was able to figure something like out when using filled.contour(...), e.g.
filled.contour(ak.fan, levels = c(70, 73, 76, 80, 90), color = terrain.colors)
(I still couldn't get the Red->yellow->green transition figured out for this
example...ugh...need more caffeine)
I am hoping a similar amount of control is available using image:
library(akima)
hyp_distance<-seq(1,15)
angle_deg_val<-seq(0,15)
x_distance_val<-NULL
y_distance_val<-NULL
for(ii in 1:length(hyp_distance))
{
for(jj in 1:length(angle_deg_val))
{
x_distance_tmp<-hyp_distance[ii]*cos(angle_deg_val[jj]*pi/180)
y_distance_tmp<-hyp_distance[ii]*sin(angle_deg_val[jj]*pi/180)
x_distance_val<-c(x_distance_val, x_distance_tmp)
y_distance_val<-c(y_distance_val, y_distance_tmp)
}
}
temperature_vals<-rnorm(length(x_distance_val), 75, 2.2)
temp_samples<-cbind(x_distance_val, y_distance_val, temperature_vals)
ak.fan <- interp(temp_samples[,1],temp_samples[,2],temp_samples[,3] )
filled.contour(ak.fan, levels = c(70, 73, 76, 80, 90), color = terrain.colors)
image(ak.fan)
More information about the R-help
mailing list