Skip to content

Support vmin/vmax with bins='log' in hexbin #20729

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

Merged
merged 2 commits into from
Jul 30, 2021
Merged

Support vmin/vmax with bins='log' in hexbin #20729

merged 2 commits into from
Jul 30, 2021

Conversation

svank
Copy link
Contributor

@svank svank commented Jul 24, 2021

PR Summary

Matplotlib 3.3 deprecated passing norm and vmin or vmax parameters simultaneously to certain functions. The hexbin plotting method supports a bins='log' parameter that applies logarithmic scaling to the colormap of the resulting histogram. Under the hood, this behavior is implemented by generating a LogNorm and setting it to the norm parameter. This means that plt.hexbin([], [], bins='log', vmin=1) raises a deprecation warning (or error in the dev branch), Passing parameters norm and vmin/vmax simultaneously is deprecated... Please pass vmin/vmax directly to the norm when creating it.

This error is confusing since the user didn't create a norm, and the bins='log' parameter seems to be a convenience to let the user avoid importing and creating a LogNorm, so I think any vmin/vmax parameters should be accounted for when creating the LogNorm under the hood. This PR does that and adds a test for this situation.

The incompatibility between bins='log' and vmin/vmax is not mentioned in the docs, so I don't think this PR needs any doc changes.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [N/A] New features are documented, with examples if plot related.
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [N/A] Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@QuLogic QuLogic merged commit 64e898a into matplotlib:master Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants