Skip to content

Instantly share code, notes, and snippets.

@joferkington
Created June 10, 2015 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joferkington/7517ded854aaffc8254a to your computer and use it in GitHub Desktop.
Save joferkington/7517ded854aaffc8254a to your computer and use it in GitHub Desktop.
Quick example of masking 0-count portions of a 2D histogram
import numpy as np
import matplotlib.pyplot as plt
x, y = np.random.normal(0, 1, (2, 1000))
counts, ybins, xbins = np.histogram2d(y, x, bins=30)
counts = np.ma.masked_equal(counts, 0)
fig, ax = plt.subplots()
ax.pcolormesh(xbins, ybins, counts)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment