Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add 'density' kwarg to histogram#8993
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lib/matplotlib/tests/test_axes.py Outdated
ax.hist((d1, d2), stacked=True, normed=True, density=False) | ||
def test_hist_stacked_density(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This test needs a different name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This test was being covered by one of the other added ones anyway, so I've just got rid of it.
Adding strict coverage changes on thetests was a brilliant idea (not sure who suggested that, but I owe them a drink of their choice). |
lib/matplotlib/axes/_axes.py Outdated
set, then that value will be used. If neither are set, then the | ||
args will be treated as ``False``. | ||
If both are set to different things, the hist function raises an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should be 'if both are set'
@dstansby Can you squash this to three commits (one each for the code from@chelseatroy and@moboehle and a third of your changes)? |
…istent with numpyReformatted according to pep8Added tests for density. Style fixes in hist function. Density and normed cannot be set to not None at the same time anymore.Density and normed cannot be set to not None at the same time anymore.
Update documentation to reflect addition of density arg to histAdjust documentation and test formattingRaise if density and normed are both set in histUpdate documentation to match pep8 guidelines
Remove changes to pyplot.pyRemove accidental normalize imput methodPEP8 new testsOnly check for double kwargs onceRemove duplicate test and parametrize testSmall docstring fix
I think that's worked... |
lib/matplotlib/axes/_axes.py Outdated
normed : boolean, optional | ||
If `True`, the first element of the return tuple will | ||
density : boolean, optional | ||
If ``True``, the first element of the return tuple will | ||
be the counts normalized to form a probability density, i.e., | ||
the area (or integral) under the histogram will sum to 1. | ||
This is achieved dividing the count by the number of observations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is achieved by dividing the
# We will handle the normed kwarg within mpl until we | ||
# get to the point of requiring numpy >= 1.5. | ||
hist_kwargs = dict(range=bin_range) | ||
density = bool(density) or bool(normed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
why do you need to cast it to bool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ifdensity
/normed
isNone
thenbool(None)
evaluates toFalse
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We don't strictlyneed the cast to bool, but it also does not hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
but doesn't if None also evaluate to false when it's not an equality operation?
Going to merge since there's two approvals |
This change is frommatplotlib#8993
This change is frommatplotlib#8993
This change is frommatplotlib#8993
This change is frommatplotlib#8993
Uh oh!
There was an error while loading.Please reload this page.
This is a merge of#7856 and#8408, both of which helped to introduce the
density
kwarg tohistogram
. Will definitely want a squash when it goes in as there were lots of little tricky bits to fix.Fixes#7364