Last active
February 23, 2016 19:38
-
-
Save jaredjburgess/52e6afe440c5ad3d291c to your computer and use it in GitHub Desktop.
Normalised histogram using matplotlib.pyplot.hist and numpy weights
This file contains 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 | |
counts = [10, 8, 6, 14] | |
weights = np.ones_like(counts) / float(len(counts)) | |
plt.figure(figsize=(10, 5)) | |
plt.hist(counts, bins=range(1, max(counts)+2), align='left', weights=weights) | |
plt.xticks(range(1, max(counts)+1)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment