[R-sig-Geo] newbie: spplot/ colour ramps
Oehler, Friderike (AGPP)
Friderike.Oehler at fao.org
Tue Apr 8 10:27:16 CEST 2008
Thanks Edzer, I shall try again:
1) I would like to use spplot to map my factor "TYP" as dots of different
colours, however the resulting plot uses the same colours for the first and
last value (10,40). I guess that my use of the "cuts" argument is wrong, but
I can't find any better:
LAT <-c(-6.5, -5.5, -9.5, -8.5, -7.5, -6.5, -7.5, -6.5)
LON <-c(31.5, 31.5, 32.5, 32.5, 32.5, 32.5, 33.5, 33.5)
TYP <-c(rep(c(10,20,30,40),2))
a1<- as.data.frame(cbind(LON, LAT, TYP))
coordinates(a1)<- ~ LON + LAT
a1$TYP<-as.factor(a1$TYP)
spplot(a1, zcol="TYP", cuts=c(10,20,30,40), col.regions=heat.colors(4),
scales=list(draw=TRUE))
2) I would then like to overlay these dots over the SpatialPolygonsDataFrame
of an imported shapefile EA:
points <- list("sp.points", a1, zcol="TYP",
cuts=c(10,20,30,40),col.regions=heat.colors(4),pch=19)
spplot(EA, zcol='ADM0_CODE', sp.layout=list(points), scales=list(draw=TRUE),
col.regions='transparent', colorkey=FALSE, xlim=c(31,34), ylim=c(-10,-5))
Does this work? I only get unicoloured dots and am not sure whether this is
due to my problem 1) or whether there is another error.
Very grateful for any help,
Friderike
More information about the R-sig-Geo
mailing list