简体   繁体   中英

log color scale with spplot

How can I have a log color scale in spplot color key? Ie so that in this map: 在此输入图像描述

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM