Exercise

Customizing a diverging palette heatmap

The default color scheme used by Seaborn's heatmap() doesn't give the value of 0 any special treatment. This is fine for instances when 0 isn't special for the variable you're visualizing but means you will need to customize the palette when 0 is special, such as when it represents a neutral value.

For this visualization, you want to compare all the cities against the average pollution value for CO in November 2015. (As is provided in the DataFrame nov_2015_CO).

To do this, use a heat map to encode the number of standard deviations away from the average each city's CO pollution was for the day. You'll need to replace the default palette by creating your own custom diverging palette and passing it to the heatmap and informing the function what your neutral value is.

Instructions

100 XP
  • Pass the diverging palette to your plot.

    • Note that the sns.heatmap() function in Seaborn does not have a palette argument but instead requires the cmap argument.
  • Add your neutral value to the heat map by specifying the center argument.

  • Set the upper and lower boundaries to the color bar to -4 and 4 to make the legend symmetric.