I am using the levelplot
function of the awesome rasterVis
package to create a map whose values diverge around zero. I am plotting a raster file using a red to blue palette, but I am trying to assign grey to zero values in the map.
Specifically, I want to reproduce the colors of this figure:
Notice that where a red to blue scale is used, but zero values have been colored with grey.
Currently, my maps looks like this:
And this is the code to reproduce it (file available at https://www.dropbox.com/s/cypfdu1eaz2fuok/r.annual.tif?dl=0):
# Load required packages
library(rasterVis)
# open file
r.annual <- raster("Downloads/r.annual.tif")
# Set color palette
myTheme=rasterTheme(region=brewer.pal('RdBu', n=11))
# Plot
levelplot(annual.mask, par.settings=myTheme, margin=F)
How can I assign grey to all zero values in my map above?