[R-sig-Geo] spplot how to control variable scale with colorkey()

Pierre Roudier pierre.roudier at gmail.com
Thu Jul 29 07:09:54 CEST 2010


I'm not completely sure to understand your question properly, but I
think ggplot2 can be a solution to your problem, I find it great to
plot spatial data:

library(sp)
library(ggplot2)

# For gridded data
data(meuse.grid)
gridded(meuse.grid) <- ~x+y
ggplot(data=as.data.frame(meuse.grid), aes(x=x, y=y)) +
geom_tile(aes(fill=dist)) + scale_fill_gradientn("My variable",
colours=terrain.colors(255)) + coord_equal()

# For ungridded data
data(meuse)
coordinates(meuse) <- ~x+y
ggplot(data=as.data.frame(meuse), aes(x=x, y=y)) +
geom_point(aes(colour=lead)) + scale_colour_gradientn("My variable",
colours=rainbow(255)) + coord_equal()

For more tweaking see ?scale_colour_gradientn ?scale_fill_gradientn
and other ggplot2 ressources.

Hope this helps,

Pierre

2010/7/28 Paulo Eduardo Cardoso <paulo.mailing.list at gmail.com>:
> While plotting with spplot, the legend space is reflecting the scale
> of the variable.
>
> eg, by dping something like this:
> spplot(...,
> colorkey = list(at = c(0, 5, 10, 20, 50,100), labels = c("0", "< 5",
> "[5, 10)", "[10, 20)",
>  "[20, 50)", ">= 50"), space="bottom"))
>
> spaces between each colour interval will be proportional to the scale
> of this particular variable.
>
> Can one control this, forcing a equal interval space to the legend at colorkey?
>
> Paulo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list