Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee3d090

Browse files
committed
BUG: Fix _extent not set in PcolorImage
Fixes #8426. Added test to check `extent`: `lib/matplotlib/tests/test_image.py::test_pcolorimage_extent()`
1 parent e10c523 commit ee3d090

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5847,6 +5847,7 @@ def pcolorfast(self, *args, **kwargs):
58475847
norm=norm,
58485848
alpha=alpha,
58495849
**kwargs)
5850+
im.set_extent((xl, xr, yb, yt))
58505851
self.add_image(im)
58515852
ret = im
58525853

lib/matplotlib/tests/test_image.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@ def test_pcolorimage_setdata():
561561
assert im._A[0, 0] == im._Ax[0] == im._Ay[0] == 0, 'value changed'
562562

563563

564+
def test_pcolorimage_extent():
565+
im = plt.hist2d([1, 2, 3], [3, 5, 6],
566+
bins=[[0, 3, 7], [1, 2, 3]])[-1]
567+
assert im.get_extent() == (0, 7, 1, 3)
568+
569+
564570
def test_minimized_rasterized():
565571
# This ensures that the rasterized content in the colorbars is
566572
# only as thick as the colorbar, and doesn't extend to other parts

0 commit comments

Comments
 (0)