[R-sig-Geo] fixed colors in maps (Katona Lajos)

Katona Lajos katona at statisztikus.hu
Mon Dec 29 14:57:53 CET 2008


Hi,
there is an example here:

library(sp)
library(lattice)
library(RColorBrewer)
data(meuse)
coordinates(meuse) <- ~x+y
meuse$color_codes=as.numeric(meuse$ffreq)+as.numeric(meuse$soil)+as.numeric(meuse$lime)
meuse$color_codes[1:3]=1
meuse$color_codes[4:7]=2
meuse$color_codes[16:20]=8
meuse$color_codes[21:26]=9
meuse$color_codes2=meuse$color_codes
meuse$color_codes3=meuse$color_codes
meuse$color_codes2=ifelse(meuse$color_codes2<4,meuse$color_codes2,3)
meuse$color_codes3=ifelse(meuse$color_codes3>6,meuse$color_codes3,6)
meuse$color_codes=as.factor(meuse$color_codes)
meuse$color_codes2=factor(meuse$color_codes2, levels=c(1,2,3,4,5,6,7,8,9))
meuse$color_codes3=factor(meuse$color_codes3, levels=c(1,2,3,4,5,6,7,8,9))
#good
spplot(meuse, "color_codes", col.regions=brewer.pal(9, "Reds"))
#wrong (I'd like to see every code of colors in legend, and only the first 3
colors from the 9 in the map)
spplot(meuse, "color_codes2", col.regions=brewer.pal(9, "Reds"))
#wrong (I'd like to see every code of colors in legend, and only between 6 and
9 colors from the 9 in the map)
spplot(meuse, "color_codes3", col.regions=brewer.pal(9, "Reds"))

Best regards,
Lajos Katona


On Sun, 28 Dec 2008 12:36:35 +0100, Edzer Pebesma
<edzer.pebesma at uni-muenster.de> wrote:
> Could you provide me and/or the list with an example that we can
> reproduce and that illustrates your problem?
> --
> Edzer




More information about the R-sig-Geo mailing list