On 02/09/2010 04:45 AM, FMH wrote:

Hi,

The script below is my current coding in order to produce a contour plot of 
temperature across altitude and time. In my case, time,altitude and temperature 
are represented by x, y and z variables.


##############################################
Brazilan.Pallete<- colorRampPalette(c("blue","green","yellow","red"))
image.plot(x, y, z, col = Brazilan.Pallete(50))
contour(x,y,z, levels = seq(1, 40, by = 1), add = TRUE, col = 'peru')
##############################################



The plot worked fine but i found difficult to fix the interval of the color 
corresponding to z value. In my case, the range of z values is between 1 and 40 
and  i'd like to fix the color in the image correspoding to four sub-intervals 
of z values. For instance:

1. 1<  z<  10 : blue
2. 11<  z<  20: green
3. 21<  z<  30: yellow
4. 31<  z<  40 : red.

I did't find a suitable code to do this. Could someone please give an advice on 
this matter?

Hi Fir,
The above is saying to me that you want to do this:

zcol<-c("blue","green","yellow","red")[z%/%10+1]
image.plot(x, y, z, col = zcol)

However, if you mean:

1 < z <= 10 : blue
...

you would have to do something like:

zcol<-c("blue","green","yellow","red")[(z-0.001)%/%10+1]

Jim

______________________________________________
R-help@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.

Reply via email to