r - 如何反转RasterVis(Levelplot)的默认颜色?

标签 r colors raster levelplot rastervis

我想使用 levelplot 的默认颜色,但顺序相反。我知道如何反转自定义颜色,但无法对 rasterVis 的默认颜色进行反转。 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)

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

感谢您的帮助。

最佳答案

rasterThemelatticeExtracustom.theme.2 函数的定制,使用 `viridisLite 包的 magma 调色板:

     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)

revMagma

关于r - 如何反转RasterVis(Levelplot)的默认颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64347711/

相关文章:

java - 相同的颜色在不同的 View 中显示不同

python - 如何获得 matplotlib 中最后一个图形的颜色?

bash - 使大型光栅文件中除一个以外的所有值都为 0

从 wrld_simpl 全局 map 中移除南极洲

r - R 中 svm 特征选择的示例

r - 在ggplot中用geom_tile绘制连续的强度

css - Twitter 如何从图像像素数据中提取有意义的主题颜色?

r - 使用 grid.raster 在列表中的每个 ggplot 对象上叠加图像的方法?

r - 将字符串附加到列表中的日期项时如何保持 POSIXct 格式?

r - 从 Excel 移动到 R : How to manipulate data based on specific cell-values?