Skip to content
Prev 333680 / 398506 Next

specify breaks in divergent palette in RColorBrewer: was divergent colors around zero in levelplot()

On Mon, 25 Nov 2013, C. Alina Cansler wrote:

            
These colors are not very well balanced because "blue" is much darker than 
"red". You can see that more clearly when you desaturate the colors where 
the blue branch corresponds to darker colors than the red branch.

The palettes in RColorBrewer or colorspace offer better balanced palettes. 
Consider the code below.

And as for the original question: diverge_hcl(99) would be one option to 
obtain 99 divergent colors in "colorspace".

library("colorspace")
pal <- function(col, border = "light gray") {
   n <- length(col)
   plot(0, 0, type="n", xlim = c(0, 1), ylim = c(0, 1),
     axes = FALSE, xlab = "", ylab = "")
   rect(0:(n-1)/n, 0, 1:n/n, 1, col = col, border = border)
}

par(mfrow = c(2, 2), mar = rep(1, 4))
pal(div.colors(9))
pal(diverge_hcl(9))
pal(desaturate(div.colors(9)))
pal(desaturate(diverge_hcl(9)))