Skip to content
Prev 70574 / 398525 Next

images and maps in R

On Fri, 27 May 2005, Don MacQueen wrote:

            
Both for map() in the maps package and plot.Map() and plot.polylist() in 
the maptools package, there are three things to sort out. Firstly, are the 
map polygons the same, and in the same order as the data you want to map? 
Next, which palette of colours do you want to use (the RColorBrewer 
palettes are well-chosen)? And finally, which breakpoints will you use 
for the class intervals to divide the data into colours?

If the breakpoints are brks:

cols <- brewer.pal(length(brks)-1, "your choice of palette)
col_choices <- findInterval(data, brks, all.inside=TRUE)

and your data are the same length and in the same order as the polygons, 
thematic maps are not too difficult.