3

我想使用 levelplot 的默认颜色,但顺序相反。我知道如何反转自定义颜色,但无法为 rasterVis 的默认颜色做。光栅可见

library(raster)
library(rasterVis)
##Solar irradiation data from CMSAF 
old <- setwd(tempdir())
download.file('https://raw.github.com/oscarperpinan/spacetime-vis/master/data/SISmm2008_CMSAF.zip',
              'SISmm2008_CMSAF.zip', method='wget')
unzip('SISmm2008_CMSAF.zip')

listFich <- dir(pattern='\\.nc')
stackSIS <- stack(listFich)
stackSIS <- stackSIS * 24 ##from irradiance (W/m2) to irradiation Wh/m2

idx <- seq(as.Date('2008-01-15'), as.Date('2008-12-15'), 'month')

SISmm <- setZ(stackSIS, idx)
names(SISmm) <- month.abb

setwd(old)
levelplot(SISmm)

如何反转表示较高值的黑色和表示较浅值的浅色?

感谢您的任何帮助。

4

1 回答 1

4

rasterTheme是使用`viridisLite包的岩浆调色板的custom.theme.2功能的定制:latticeExtra

     rasterTheme(region = magma(10),
             pch=19, cex=0.7, 
             strip.background = list(col = 'transparent'),
             strip.shingle = list(col = 'transparent'),
             strip.border = list(col = 'transparent'),
             add.lines = list(lwd = .4),
             ...)

因此,您应该使用region带有反转岩浆调色板的参数:

library(rasterVis)
library(viridisLite)

f <- system.file("external/test.grd", package="raster")
r <- raster(f)

revMagma <- rasterTheme(region = rev(magma(10)))
levelplot(r, par.settings = revMagma)

转岩浆

于 2020-10-14T08:49:35.103 回答