Exercise

Making a heat map - visualizing hot and cold zones

Visualizing probabilities on a grid can often be improved by using color. In this case, the figure could be referred to as a heat map. There are several ways to build heat maps in R, but in this exercise, you'll do it with ggplot2.

The color of each zone in your heat map will correspond to the probability of making contact. Scaling colors in this way gives an additional visual edge so that the locational impact on contact rate can be inferred and compared more quickly.

The geom_tile() function does this automatically, but you will customize the color scheme with the scale_fill_gradientn() function in combination with brewer.pal() from the RColorBrewer package. (RColorBrewer provides some nice color schemes that would be time-consuming to reproduce manually. You will use mostly red colors here, but you can type display.brewer.all() in the R console to see the available color palettes.)