[R-sig-Geo] add legend to plot(spatialpolygonsdataframe)
cribeiro at ualg.pt
cribeiro at ualg.pt
Sat Jul 31 15:12:46 CEST 2010
Hello, Paulo
My suggestion is
library(maptools) # loads sp library too
library(RColorBrewer) # creates nice color schemes
library(classInt) # finds class intervals for continuous variables
file.shp <- readShapePoly("yourfile.shp")
plotvar <- file.shp at data$your_var_to_be_plot
nclr <- 8
plotclr <- brewer.pal(nclr,"BuPu")
class <- classIntervals(plotvar, nclr, style="quantile",dataPrecision=0)
colcode <- findColours(class, plotclr)
plot(file.shp)
plot(file.shp, col=colcode, add=T)
title(main="your title")
sub="Quantile (Equal-Frequency) Class Intervals")
legend(locator(1), legend=names(attr(colcode, "table")),
fill=attr(colcode, "palette"), cex=0.6, bty="n")
Conceição Ribeiro
----------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Re_ [R-sig-Geo] add legend to plot(spatialpolygonsdataframe).pdf
Type: application/pdf
Size: 5193 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100731/6a40cbc4/attachment.pdf>
More information about the R-sig-Geo
mailing list