Skip to content
Prev 333582 / 398506 Next

divergent colors around zero in levelplot()

On Fri, 22 Nov 2013, Don McKenzie wrote:

            
One approach is to limit the range of colors (to match the range of the 
data) as you suggest above. The other approach is to extend the range of 
the legend (beyond the range of the data). For example:

levelplot(z ~ x*y, grid, at = seq(-12, 12, length = 100))

This produces a legend that is symmetric around zero.

For other/better diverging color palettes, you can use the RColorBrewer 
package (as suggested by Bert) or the colorspace package (see e.g., its 
graphical choose_color() tool).