Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hist won't norm for small numbers #6353

Closed
kilojoules opened this issue Apr 30, 2016 · 3 comments
Closed

hist won't norm for small numbers #6353

kilojoules opened this issue Apr 30, 2016 · 3 comments
Labels
status: needs clarification Issues that need more information to resolve.

Comments

@kilojoules
Copy link

kilojoules commented Apr 30, 2016

osx 10.10.5 python 2.7, matplotlib installed from github's setup.py

When I plot a histogram of small values, the normalize option doesn't work.

from matplotlib import pyplot as plt
import numpy as np
y = list(np.random.normal(.05,.003,100)) + list(np.random.normal(.03,.001,100))
plt.hist(y, normed=True)
plt.show()

un-normed hist

@tacaswell
Copy link
Member

What do you expect to happen? This looks naively looks correct to me. The norm kwarg noramizes the probability density (docs), that is the integral of the histogram (not the sum) is 1

@tacaswell tacaswell added this to the unassigned milestone Apr 30, 2016
@tacaswell tacaswell added the status: needs clarification Issues that need more information to resolve. label Apr 30, 2016
@kilojoules
Copy link
Author

I understand now. This was unintuitive for me.

@tacaswell
Copy link
Member

I think you can get the bins to sum to 1 if you pass in a weight vector of 1/n and drop the norm kwarg.

If you have any other follow up questions about this I suggest sending them to matplotlib-user@python.org (and you might have to sign up for the mailing list to post un-moderated).

tacaswell added a commit that referenced this issue May 9, 2016
DOC: Minor improvements to histogram docs

closes #6353 and closes #6357
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

No branches or pull requests

2 participants