[R-sig-Geo] plotting polygons of one shapefile in different colors?

cyndy-jer cyndyh at nmsu.edu
Thu Sep 26 20:44:01 CEST 2013


Hi Maren - 

(yes I'm Cyndy :) 

Well, thanks, but yikes!  Surely there is an easier way?  I've gotten pretty
close by trying to use spplot and rColorBrewer, but I'm not quite there.  I
have 3 'n' values as part of my SpatialPolygonDataFrame, and somehow the
below only plots 2 of them, 

(my dataframe is named 'gimmie')

numpoly=length(unique(gimmie$n))

# the below yields a plot of three colors
display.brewer.pal(numpoly, "Accent")

#the below yields my map but with only two of the three above colors, yet
the scale bar shows
#three colors with the three values I KNOW are in my 'n' values in the
shapefile
spplot(gimmie, c("n"), xlim=c(minx,maxx), ylim=c(miny,maxy),
col.regions=brewer.pal(numpoly, "Accent"))

? I don't see why this doesn't work as I expect.  Any ideas, anyone?



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/plotting-polygons-of-one-shapefile-in-different-colors-tp7584720p7584727.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list