Simplest possible heatmap with ggplot2

Featuring the lovely “spectral” palette from Colorbrewer. This really just serves as a reminder of how to do four things I frequently want to do:

  1. Make a heatmap of some kind of matrix, often a square correlation matrix
  2. Reorder a factor variable, as displayed along the axis of a plot
  3. Define my own color palette with colorRampPalette()
  4. Use RColorBrewer, specifically the diverging “spectral” scheme