Skip to content
Prev 333669 / 398506 Next

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

Bert or anyone else familiar with RColorBrewer:

Has anyone tried to accomplish with RColorBrewer what I asked about in my original post (below)? 

Here is an example cribbed from the levelplot() help examples

x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))

# now use RColorBrewer to get a palette

library("RColorBrewer?)
levelplot(z~x*y, grid,col.regions=brewer.pal(6,"BrBG?))   # the numeric argument to brewer.pal is the number of colors used ? I tried several

This gives me a nice brown-to-green gradient but does not (AFAICS) give me control over where the center of the divergence lies. Even in this symmetrical
example, I can?t get it to be at zero ? it repeats on either side of zero.

thanks to anyone who pages through all this and makes a suggestion, even if it doesn?t work.  :-)
On Nov 22, 2013, at 10:25 PM, Bert Gunter <gunter.berton at gene.com> wrote:

            
Don McKenzie
Research Ecologist
Pacific Wildland Fire Science Lab
US Forest Service

Affiliate Professor
School of Environmental and Forest Sciences
University of Washington
dmck at uw.edu