在 levelplot 中将刻度线放在每种颜色的中间
Place ticks in middle of each colors in levelplot
我试图将刻度线和名称放在色键中每种颜色的中间,但无法做到。是否可以在 levelplot 中移动颜色中间的刻度?
> library (raster)
> ras <- list.files("/filepath/", pattern = "\.tif$", full=TRUE)
> s <- stack(ras)
> levelplot(s, colorkey=list(at=seq(-3, 4, 1), labels=list(at=c(-3, -2, -1, 0, 1, 2,3, 4), labels=c("AA", "BB", "CC", "DD","EE", "FF", "GG")))
您可以尝试这样的操作:
library (raster)
library(rasterVis)
ras <- lapply(1:3,function(i){
r <- raster()
values(r) <- sample(x = 1:10,size = ncell(r),replace = TRUE)
r
})
s <- stack(ras)
levelplot(s, colorkey=list(at=seq(-3, 4, 1),
labels=list(at=c(-2.5, -1.5, -0.5,0.5, 1.5,2.5,3.5),
labels=c("AA", "BB", "CC", "DD","EE", "FF", "GG"))))
我试图将刻度线和名称放在色键中每种颜色的中间,但无法做到。是否可以在 levelplot 中移动颜色中间的刻度?
> library (raster)
> ras <- list.files("/filepath/", pattern = "\.tif$", full=TRUE)
> s <- stack(ras)
> levelplot(s, colorkey=list(at=seq(-3, 4, 1), labels=list(at=c(-3, -2, -1, 0, 1, 2,3, 4), labels=c("AA", "BB", "CC", "DD","EE", "FF", "GG")))
您可以尝试这样的操作:
library (raster)
library(rasterVis)
ras <- lapply(1:3,function(i){
r <- raster()
values(r) <- sample(x = 1:10,size = ncell(r),replace = TRUE)
r
})
s <- stack(ras)
levelplot(s, colorkey=list(at=seq(-3, 4, 1),
labels=list(at=c(-2.5, -1.5, -0.5,0.5, 1.5,2.5,3.5),
labels=c("AA", "BB", "CC", "DD","EE", "FF", "GG"))))