Repository navigation
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
_extentof AxesImage on its creation.PR Summary
Depending on bins argument of hist2d, style is set to either
imageorpcolorimagein _axes.pcolorfast. If the style isimage, AxesImage object is created and is supplied with extents. The issue arose when style waspcolorimage. The_extentis never set in super class AxesImage of PcolorImage.The issue is solved by setting
_extentafter PcolorImage creation.This PR fixes #8426.
PR Checklist