Created
June 10, 2015 21:03
-
-
Save joferkington/7517ded854aaffc8254a to your computer and use it in GitHub Desktop.
Quick example of masking 0-count portions of a 2D histogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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