45. Matplotlib: A simple heatmap

This post is also available as a PDF and as a Jupyter Notebook.

Heatmaps may be generated with imshow.

We import a colour map from the library cm.

For a list of colour maps available see: https://matplotlib.org/examples/color/colormaps_reference.html

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm # This allows different color schemes

# Generate an array of increasing values
a = a.reshape(20,20)

# Plot the heatmap using 'inferno' from the cm colour schemes

plt.imshow(a,interpolation='nearest', cmap=cm.inferno)

# Add a scale bar




One thought on “45. Matplotlib: A simple heatmap

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s