diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index e32b734a455d..41a7b09f7a29 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5847,6 +5847,7 @@ def pcolorfast(self, *args, **kwargs): norm=norm, alpha=alpha, **kwargs) + im.set_extent((xl, xr, yb, yt)) self.add_image(im) ret = im diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 0a16e97848f6..7f4f9920190e 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -561,6 +561,12 @@ def test_pcolorimage_setdata(): assert im._A[0, 0] == im._Ax[0] == im._Ay[0] == 0, 'value changed' +def test_pcolorimage_extent(): + im = plt.hist2d([1, 2, 3], [3, 5, 6], + bins=[[0, 3, 7], [1, 2, 3]])[-1] + assert im.get_extent() == (0, 7, 1, 3) + + def test_minimized_rasterized(): # This ensures that the rasterized content in the colorbars is # only as thick as the colorbar, and doesn't extend to other parts