plot - Assigning colours to polygons for a large number of categories on a map in R -


i attempting plot map of different vegetation types have called grass. categories listed under grass@data$legend. there 72 in total. not care colours there must different colour each vegetation type , of vegetation types appear more 1 polygon.

poly<-readogr(".","vegmap2006_geo") out <- crop(poly, extent(20, 35,-26, -32)) grass<-poly[poly@data$biome%in%"grassland biome",]  colours<-terrain.colors(72) plot(grass,col=colours[grass$legend],border=na) 

nothing happens when plot , have no idea why. can plot map following code

plot(grass,col=grass$legend, border=na) 

however r colour palette not contain enough colours each vegetation type coloured differently

help colors. getting list of colors available in r, type

 colors()  # colors 

for getting specific shades of color, let's redor blue or green or orange type

 colors()[grep("red",colors())]           # shades of red  colors()[grep("blue",colors())]          # shades of blue  colors()[grep("green",colors())]         # shades of green  colors()[grep("orange",colors())]        # shades of orange 

Comments