Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.