-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
BUG: Fix _extent
not set in PcolorImage
#9442
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
BUG: Fix _extent
not set in PcolorImage
#9442
Conversation
Thanks for this! Can you supply a test that doesn't work w/ master but does work with your suggested change? It'd help (me?) to get context for it. |
@jklymak Sample example from issue:
The issue arose when plt.hist2d returns object of matplotlib/lib/matplotlib/axes/_axes.py Lines 5781 to 5795 in d7ddd47
Followed by creation of object: matplotlib/lib/matplotlib/axes/_axes.py Lines 5837 to 5842 in d7ddd47
or matplotlib/lib/matplotlib/axes/_axes.py Lines 5845 to 5850 in d7ddd47
Here extent was not specified while creation of the PcolorImage object. matplotlib/lib/matplotlib/image.py Line 980 in d7ddd47
PcolorImage calls AxesImage constructor with extent=None, which causes error when referenced. In short, to recreate error, create any PcolorImage object and reference its parent's(AxesImage) extents. To do this, elements of bins must be of dim 1 and size >=3, with intervals such that the do not satisfy: matplotlib/lib/matplotlib/axes/_axes.py Lines 5789 to 5795 in d7ddd47
Basically some non-equally spaced bins. |
Could you add the test in |
Fixes #8426. Added test to check `extent`: `lib/matplotlib/tests/test_image.py::test_pcolorimage_extent()`
Changed the way @dstansby Added test. |
Backport PR #9442 on branch v2.1.x
PcolorImage now sets
_extent
of AxesImage on its creation.PR Summary
Depending on bins argument of hist2d, style is set to either
image
orpcolorimage
in _axes.pcolorfast. If the style isimage
, AxesImage object is created and is supplied with extents. The issue arose when style waspcolorimage
. The_extent
is never set in super class AxesImage of PcolorImage.The issue is solved by setting
_extent
after PcolorImage creation.This PR fixes #8426.
PR Checklist