Last active
February 12, 2016 13:39
-
-
Save nomeyer/031d97e4cf3170243fa4 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