如何设置阶梯色区域? [英] How to set up step color regions?
本文介绍了如何设置阶梯色区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于levelplot
/spplot
,我们可以使用at
定义颜色区域范围(最小,最大,间隔).我的问题是:如何将红色用于大于29.5的值?
With levelplot
/spplot
we can use at
to define the color region range (min, max, interval). My question is: how can I use red for values greater than 29.5?
This is my sample NCDF file --> download here
library (raster)
r <- brick('bali.nc', varname='TEMPERATURE', level=1)
library(rasterVis)
jet <- colorRampPalette(
c('#00007F', 'blue', '#007FFF', 'cyan', 'yellow', '#FF7F00', 'red', '#7F0000')
)
# First Figure - without at
levelplot(r, layer=1, margin=F, contour=F, col.regions=jet)
# Second Figure - with at
levelplot(r, layer=1, margin=F, contour=F, col.regions=jet, at=seq(27.5, 29.5, 0.1))
推荐答案
您必须在中断值向量中包括最大值,并相应地定义调色板:
You have to include the maximum value in the vector of break values, and define the palette accordingly:
rMax <- cellStats(r, max)
myAt <- c(seq(27.5, 29.5, 0.1), rMax[1])
myPal <- jet(length(myAt) - 1)
levelplot(r, layer = 1, margin = FALSE,
at = myAt,
par.settings = rasterTheme(myPal))
这篇关于如何设置阶梯色区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文