Dear all, I've uploaded a new sp version to /incoming on CRAN (0.9-29) where spplot should deal better with factors as dependent variables. As levelplot does not really have this functionality, it involved a bit of work on the spplot side. Now, spplot checks that all factors in layers (panels) have the same levels; I cannot see use of paneled plots for factors having different levels; this means that the example Jon Loehrke gave, to which I reacted with a note that the resulting plot was wrong on https://stat.ethz.ch/pipermail/r-sig-geo/2008-December/004729.html now breaks with an error condition. Please convince me if you think this is bad design. Also, when plotting factors, the length of the col.regions color ramp now needs to equal the number of factor levels. An exception is when plotting points; in this case a single color is also accepted (because you may want to use point symbols to distinguish classes). The default color setting for factors is still that for continuous variables (the cm.colors() default of lattice); I'm quite unhappy about this but am also reluctant to make sp dependent on RColorBrewer. Please test & comment; happy new year! -- Edzer
Katona Lajos wrote:
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/ http://www.springer.com/978-0-387-78170-9 e.pebesma at wwu.de