Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Turning Up the Heat > Filling with Color Gradients

Filling with Color Gradients

R has some decent built-in color gradient functions (?rainbow to learn more)—we will need a different color for each non-zero level plus one extra for zero foreclosures.

  > mapColors<-heat.colors(max(myTrtFC)+1,alpha=.6)[max(myTrtFC)-myTrtFC+1] 

Our plot is virtually the same but we add the color vector argument (col). We can easily add a legend with the sequence 10 through 0 foreclosures and its corresponding heat levels (Figure 4).

  > plotPolys(myShapeFile,axes=FALSE,bg="beige",main="Philadelphia County\n
              June 2009 Foreclosure Heat Map",xlab="",ylab="",col=mapColors) 
  > legend("bottomright",legend=max(myTrtFC):0,
    fill=heat.colors(max(myTrtFC)+1,alpha=.6),

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint