Support vmin/vmax with bins='log' in hexbin #20729
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Matplotlib 3.3 deprecated passing
norm
andvmin
orvmax
parameters simultaneously to certain functions. The hexbin plotting method supports abins='log'
parameter that applies logarithmic scaling to the colormap of the resulting histogram. Under the hood, this behavior is implemented by generating aLogNorm
and setting it to thenorm
parameter. This means thatplt.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 aLogNorm
, so I think any vmin/vmax parameters should be accounted for when creating theLogNorm
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
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).