[R] Level Plot and Scale of Colorkey

emma hartnett emma_hartnett at yahoo.co.uk
Fri Jun 13 18:50:58 CEST 2008

I am drawing level plots but I would like to specify the range of the colorkey, I am not having any success figuring this out so any help would be greatly appreciated!

Here is an example of what I am trying to do:


x <- seq(1, 10,by=1) 
y <- seq(1,10,by=1)
g <- expand.grid(x = x, y = y)
g$z <- 1/exp((abs(g$x-5)+abs(g$y-5))*disp)

levelplot(z ~ x * y, g,xlab="x co-ordinate", ylab="y co-ordinate" ,colorkey=TRUE,col.regions=(col=gray((0:32)/32)))

I would like to enforce the number of divisions on the colorkey scale and the size – so for example from 0 to 0.1 in increments of 0.02 (just as an example).  

I apologize if this is an obvious question but I have read the documentation and scoured the archives and cannot figure it out.


More information about the R-help mailing list