1
votes

How can I have a log color scale in spplot color key? I.e. so that in this map: enter image description here

that instead of 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 the numbers on the scale go like 0.0, 0.01 0.1 0.2 0.5 1.0 or something like this?

I tried the do.log argument, but it only works for SpatialPointsDataFrame (according to the docs). I also tried the scales argument:

data(meuse.grid)
gridded(meuse.grid)=~x+y
spplot(meuse.grid[,'dist'], scales=list(log="e"))

But it seems to be working only for the x and y coordinates, not the displayed variable and the color scale.

1

1 Answers

3
votes

It's a bit convoluted, but this seems to do it:

library(sp)
data(meuse.grid)
gridded(meuse.grid)=~x+y
meuse.grid$ldist = log(meuse.grid$dist)
at = c(.05,.1,.2,.4,.8)
spplot(meuse.grid[,'ldist'], at = log(at), colorkey=list(labels = as.character(at)))

I would advice to not include 0 in the log scale!