Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
dstansby merged 4 commits intomatplotlib:masterfromdstansby:hist-kwarg-fix
Aug 7, 2017

Conversation

dstansby
Copy link
Member

@dstansbydstansby commentedAug 5, 2017
edited
Loading

This is a merge of#7856 and#8408, both of which helped to introduce thedensity kwarg tohistogram. Will definitely want a squash when it goes in as there were lots of little tricky bits to fix.

Fixes#7364

@tacaswell
Copy link
Member

ax.hist((d1, d2), stacked=True, normed=True, density=False)


def test_hist_stacked_density():
Copy link
Member

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.

Copy link
MemberAuthor

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.

@tacaswell
Copy link
Member

Adding strict coverage changes on thetests was a brilliant idea (not sure who suggested that, but I owe them a drink of their choice).

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
Copy link
Member

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'

@tacaswelltacaswell added this to the2.1 (next point release) milestoneAug 5, 2017
@tacaswell
Copy link
Member

@dstansby Can you squash this to three commits (one each for the code from@chelseatroy and@moboehle and a third of your changes)?

moboehleand others added3 commitsAugust 5, 2017 18:25
…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
@dstansby
Copy link
MemberAuthor

I think that's worked...

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
Copy link
Member

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)
Copy link
Member

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?

Copy link
MemberAuthor

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.

Copy link
Member

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.

Copy link
Member

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?

@dstansby
Copy link
MemberAuthor

Going to merge since there's two approvals

@dstansbydstansby merged commit0a2324e intomatplotlib:masterAug 7, 2017
@dstansbydstansby deleted the hist-kwarg-fix branchAugust 7, 2017 20:49
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestAug 27, 2017
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestAug 27, 2017
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestAug 27, 2017
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestAug 28, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@story645story645story645 approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

Histogram compatibility with numpy
5 participants
@dstansby@tacaswell@story645@moboehle@chelseatroy

[8]ページ先頭

©2009-2025 Movatter.jp