Skip to content
Back to formatted view

Raw Message

Message-ID: <312327.72491.qm@web38303.mail.mud.yahoo.com>
Date: 2010-02-08T17:45:06Z
From: FMH
Subject: [R--gR] Color intervals in image.plot function

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?

Thank you.
Fir