Database Reference
In-Depth Information
Filling with Color Gradients
R has some decent built-in color gradient functions (enter ?rainbow to learn more)—we will
need a different color for each non-zero level, plus one extra color for zero foreclosures:
>
mapColors<-heat.colors(max(myTrtFC)+1,alpha=.6)[max(myTrtFC)-myTrtFC+1]
Our plot is virtually the same, but we need to add the color vector argument ( col ). We can
also easily add a legend with a sequence for 16 through 0 foreclosures and corresponding heat
levels ( Figure 1-4 ), and resize the legend with the cex argument:
> plotPolys(myShapeFile,axes=FALSE,bg="beige",main="Philadelphia
County\n
January 2011 Foreclosure Heat
Map",xlab="",ylab="",col=mapColors)
> legend("bottomright",legend=max(myTrtFC):0,
fill=heat.colors(max(myTrtFC)+1,alpha=.6),cex=.7,
title="Foreclosures")
Search WWH ::




Custom Search