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

Improvements and bugfixes for hexbin marginals#18875

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

Conversation

MihaiBabiac
Copy link

@MihaiBabiacMihaiBabiac commentedNov 2, 2020
edited by dstansby
Loading

PR Summary

The marginals functionality for hexbin had a couple of hidden bugs and issues:

  1. Providinghexbin with a tuple for thegridsize resulted in an error.
  2. It was possible to give theextents in the wrong order. This did not raise an error, but broke the marginals. (Error on bad input to hexbin extents #27607)
  3. The marginals were taking into account points outside of the specified limits.
  4. The bins for the marginals were not aligned in any way to the 2D hexagonal bins.
  5. The marginals tried usingreduce_C_function even whenC was not provided. With the defaultreduce_C_function, this meant applyingnp.mean to a set of ones, resulting in only binary values in the marginal.

This PR fixes these issues. It makes marginals work with tuplegridsize, raises aValueError when theextents are in the wrong order, ignores points outside the extents, aligns the bins of the marginals to the hexagonal bins and uses summation whenC is not provided.

In addition I changed the formatting of the code for the y marginal to match that of the x marginal so that it's easier to compare (and diff) them. You could consider somehow merging the two with a function, since most of the code is actually quite repetitive.

What would really be useful would be some unit tests for the hexbin marginals, but maybe someone else can help with that?

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@MihaiBabiac
Copy link
Author

This is the code I used for testing

importnumpyasnpfrommatplotlibimportpyplotaspltnp.random.seed(0)x=np.random.normal(1,1.5,1000)y=np.random.normal(1,1.5,1000)plt.figure()plt.hexbin(x,y,gridsize=7,marginals=True,reduce_C_function=np.sum,extent=(-2,5,-3,5))# extents are here in correct orderplt.grid()plt.show()plt.figure()plt.hexbin(x,y,gridsize=10,marginals=True,reduce_C_function=np.sum,extent=(-2,5,5,-3))# extents are here in wrong orderplt.grid()plt.show()

@QuLogic
Copy link
Member

Can you add tests for the new stuff?

@MihaiBabiac
Copy link
Author

I can try. It's my first time contributing here, so I'm not sure what the tests should check. Can you give me some pointers?

@QuLogic
Copy link
Member

Tests for hexbin would likely go intest_axes.py; seethe developer guide on testing for more info.

@jklymakjklymak marked this pull request as draftApril 23, 2021 15:34
@jklymak
Copy link
Member

ping for tests

@MihaiBabiac
Copy link
Author

I'm sorry for leaving it in this state, but probably in a few weeks is the earliest I'll have time to learn how the test system works and add the tests. It might make more sense for someone else to take it over.

@jklymak
Copy link
Member

I'll mark as orphaned if someone else wants to take it up. On the other hand, you are more than welcome to readopt your own baby.

The tests are inlib/matplotlib/tests and there are probably some hex bin tests you could grep for already...

MihaiBabiac reacted with thumbs up emoji

@dstansby
Copy link
Member

I'm going to try and revive this and split into multiple PRs. I'll add links in the original description at the top where the individual issues are helpfully listed.

@dstansby
Copy link
Member

Apart from the new error in the PR I opened, I think the rest of the issues were fixed (possibly by#21039?) at some point between this PR being opened and now, so I'll close this PR. Feel free to open new issues about the hexbin marginals if I've got that wrong!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@MihaiBabiac@QuLogic@jklymak@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp