I am interested in having a \"good\" divergent color pallette. One could obviously use just red, white, and blue:
img <- function(obj, nam) {
image(1:le
I find Kenneth Moreland's proposal quite useful.
It is implemented in the Rgnuplot package (install.packages("Rgnuplot") is enough, you don't need to install GNU plot). To use it like the usual color maps, you need to convert it like this:
cool_warm <- function(n) {
colormap <- Rgnuplot:::GpdivergingColormap(seq(0,1,length.out=n),
rgb1 = colorspace::sRGB( 0.230, 0.299, 0.754),
rgb2 = colorspace::sRGB( 0.706, 0.016, 0.150),
outColorspace = "sRGB")
colormap[colormap>1] <- 1 # sometimes values are slightly larger than 1
colormap <- grDevices::rgb(colormap[,1], colormap[,2], colormap[,3])
colormap
}
img(red_blue_diverging_colormap(500), "Cool-warm, (Moreland 2009)")
This it how it looks like in action compared to an interpolated RColorBrewer "RdBu":