[R-sig-Geo] spplot and diverging colorbrewer palette

Julien Barnier jbarnier at ens-lsh.fr
Fri May 30 16:34:18 CEST 2008


Hi to all,

A little question about using a diverging colorbrewer palette with
spplot. If you try the following code :

library(sp)
library(maptools)
library(RColorBrewer)

nc <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], proj4string=CRS("+proj=longlat +datum=NAD27"))
nc at data$AREA2 <- nc at data$AREA - 0.1
spplot(nc, c("AREA2"), col.regions=brewer.pal(7, "RdBu"), cuts=6,scales=list(draw = TRUE))

you should get a map of a (very dummy) variable which takes value
below and above zero. So I'd like the «0» value to be exactly at the
point where colours are changing from red to blue. However, with this
method it only works when «0» is exactly at the center of the scale.

Do you have any idea on how I could obtain the result I would like,
without specifying manually the cut points with «cuts» and «at» ?

Thanks in advance, and sorry if my question is not really clear, as I
am quite new to spplot...

Sincerely,
-- 
Julien Barnier
Groupe de recherche sur la socialisation
ENS-LSH - Lyon, France




More information about the R-sig-Geo mailing list