[R-sig-Geo] Continuous colorbar legend for a SpatialPointsDataFrame object

Pierre Roudier pierre.roudier at gmail.com
Fri Dec 24 16:03:30 CET 2010


Hey Piero,

My solution was to use the ggplot2 package. See the example below.

Cheers,

Pierre

# I don't have any R install handy here - I hope this example will run...
library(sp)
library(ggplot2)

data(meuse)
coordinates(meuse) <- ~x+y
# some geospatial operations on meuse here

meuse.df <- as.data.frame(meuse)
my.plot <- ggplot(data=meuse.df, aes(x=x, y=y)) +
geom_point(aes(colour=log(zinc))) + coord_equal()
print(my.plot)

# you can play with the color ramp - the RColorBrewer package is handy for that
library(RColorBrewer)
my.plot <- my.plot + scale_colour_gradientn('name of the legend',
brewer.pal(n=5, 'OrRd'))
print(my.plot)

2010/12/21 piero campa <piero.campa at gmail.com>:
>
> I would submit the same question.
> Piero
>
> (Pierre, did you manage somehow then?)
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Continuous-colorbar-legend-for-a-SpatialPointsDataFrame-object-tp4805804p5855549.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Scientist
Landcare Research, New Zealand



More information about the R-sig-Geo mailing list