I am trying to plot a rasterstack with a color scheme of red to blue with white in the centre. This is my code:
plot2<-diverge0(rasterstack, ramp='RdBu')
But when the stack is plotted, the colors are very light in shade. I would like to incorporate the code of 'colorspace' of :
darken(col, amount = 0.1, space = "combined")
How can I make the color palette obtained from diverge0 to be darker?
The below code is what I currently came up with
plot2<-diverge0(rasterstack, ramp='RdBu',darker=0.4)
which results in an error.
It is unclear where the
diverge0()
function comes from. If it is the one from https://gist.github.com/johnbaums/306e4b7e69c87b1826db, then it seems that you can do (disclaimer: untested):Note that rather than going through
RColorBrewer
first and then tweaking the result afterwards you could also play with the parameters ofdivergingx_hcl(11, "RdBu")
ordiverging_hcl(11, "Blue-Red 3", rev = TRUE)
. For example, you could replace the code from the third code line above (darken(...)
) with eitheror
Both make the luminance of the central gray somewhat darker (
l2 = 85
) with the former also limiting the maximum chroma (which is always lower with the latter anyway).In the latter case you can also register your custom palette with a new name, e.g.,