[R-sig-Geo] add legend to plot(spatialpolygonsdataframe)

cribeiro at ualg.pt cribeiro at ualg.pt
Sat Jul 31 14:54:54 CEST 2010


class="incorrect">class="incorrect">Helo, Paulo

class="incorrect">class="incorrect">My  
class="incorrect">class="incorrect">suggestion is

class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">library(class="incorrect">class="incorrect">maptools)     # class="incorrect">class="incorrect">loads class="incorrect">class="incorrect">sp class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">library  
too
class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">library(class="incorrect">class="incorrect">RColorBrewer) # class="incorrect">class="incorrect">creates class="incorrect">class="incorrect">nice class="incorrect">class="incorrect">color  
class="incorrect">class="incorrect">schemes
class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">class="incorrect">library(class="incorrect">class="incorrect">classInt)     # class="incorrect">class="incorrect">finds class="incorrect">class class="incorrect">intervals for class="incorrect">continuous  
class="incorrect">variables

file.class="incorrect">class="incorrect"&gt;shp <-  
class="incorrect">readShapePoly("class="incorrect">yourfile.class="incorrect">class="incorrect"&gt;shp")

class="incorrect">class="incorrect"&gt;plotvar <-  
file.class="incorrect">class="incorrect"&gt;shp at data$your_var_to_be_plot
class="incorrect">class="incorrect"&gt;class="incorrect"&amp;gt;nclr <-  
8
class="incorrect">plotclr <-  
class="incorrect">brewer.class="incorrect">pal(class="incorrect">class="incorrect"&gt;class="incorrect"&amp;gt;nclr,"class="incorrect">BuPu")
class="incorrect">class <-  
class="incorrect">classIntervals(class="incorrect">class="incorrect"&gt;plotvar, class="incorrect">class="incorrect"&gt;class="incorrect"&amp;gt;nclr,  
class="incorrect">style="class="incorrect">quantile",class="incorrect">dataPrecision=0)
class="incorrect">colcode <-  
class="incorrect">findColours(class="incorrect">class,  
class="incorrect">plotclr)

plot(file.class="incorrect">class="incorrect"&gt;shp)
plot(file.class="incorrect">class="incorrect"&gt;shp,  
col=class="incorrect">colcode, add=T)
title(main="Your title")
sub="Quantile (Equal-Frequency) Class Intervals")
legend(locator(1), legend=names(attr(class="incorrect">colcode, "table")),
fill=attr(class="incorrect">colcode, "palette"), cex=0.6, bty="n")

Conceição Ribeiro



More information about the R-sig-Geo mailing list