[R-sig-Geo] spplot and diverging colorbrewer palette
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Fri May 30 17:55:47 CEST 2008
Julien, try
> library(lattice)
> z = rnorm(100)
> x=rep(1:10,10)
> y=rep(1:10,each=10)
> levelplot(z~x+y,colorkey=list(at=-4:4))
try the colorkey argument in spplot, it should get passed on to spplot,
which wraps levelplot.
--
Edzer
Julien Barnier wrote:
> 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,
>
More information about the R-sig-Geo
mailing list