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

Remove old normalising code from plt.hist#9121

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
phobson merged 4 commits intomatplotlib:masterfromdstansby:hist-numpy-doc
Oct 19, 2017

Conversation

dstansby
Copy link
Member

This PR does a few things:

for i in xrange(nx):
# this will automatically overwrite bins,
# so that each histogram uses the same bins
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
m = m.astype(float) # causes problems later if it's an int
if mlast is None:
mlast = np.zeros(len(bins)-1, m.dtype)
if density and not stacked:
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is the old normalising code

if stacked:
if mlast is None:
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This if statement is never used due to the same statement on line 6097

@tacaswelltacaswell added this to the2.1 (next point release) milestoneAug 30, 2017
@@ -1464,6 +1464,14 @@ def test_hist_step_filled():
assert all([p.get_facecolor() == p.get_edgecolor() for p in patches])


@image_comparison(baseline_images=['hist_density'], extensions=['png'])
def test_hist_density():
np.random.seed(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you use 19680801 (JDH's birthday) as the seed?

Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Modulo changing the seed and squashing the image changes.

@dstansbydstansby modified the milestones:2.2 (next next feature release),2.1 (next point release)Sep 2, 2017
np.random.seed(19680801)
data = np.random.standard_normal(2000)
fig, ax = plt.subplots()
ax.hist(data, density=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this actually need an image test, or can we just test thatnp.histogram properly applies the density kwarg?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't think there was ever any image test that used the 'density' or 'norm'kwargs, so I thought it would be a good idea to add one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we are trying to keep image tests to things where the actual image appearance might change if code changes. So sure if there is no hist image test there should be one. If such a test does exist then this just tests the value of the bars, and I think you can do that w/o an image comparison. But I’m not passionate about it or anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Beating a dead horse, but:

np.random.seed(19680801)data=np.random.standard_normal(2000)fig,ax=plt.subplots()n,bins,patches=ax.hist(data,density=True)assertnp.isclose(np.sum(n*np.diff(bins)),1.0)

@phobsonphobson merged commitd0eb9ca intomatplotlib:masterOct 19, 2017
@dstansbydstansby deleted the hist-numpy-doc branchOctober 19, 2017 19:15
@tacaswell
Copy link
Member

@meeseeksdev backport to v2.1.x

NelleV added a commit that referenced this pull requestOct 26, 2017
@QuLogicQuLogic modified the milestones:needs sorting,v2.2.0Feb 13, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

@tacaswelltacaswelltacaswell approved these changes

@phobsonphobsonphobson approved these changes

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

Successfully merging this pull request may close these issues.

Rely on numpy to properly normalize histograms with unequal bin widths
5 participants
@dstansby@tacaswell@phobson@jklymak@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp