diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 6252c1ea008e..d28faf0ebae3 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -470,8 +470,10 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, # do not run the vmin/vmax through the same pipeline we can # have values close or equal to the boundaries end up on the # wrong side. - vrange = np.array([self.norm.vmin, self.norm.vmax], - dtype=scaled_dtype) + vmin, vmax = self.norm.vmin, self.norm.vmax + if vmin is np.ma.masked: + vmin, vmax = a_min, a_max + vrange = np.array([vmin, vmax], dtype=scaled_dtype) A_scaled -= a_min vrange -= a_min diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 34039fefefb4..77d25b89a625 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -853,6 +853,14 @@ def test_mask_image(): ax2.imshow(A, interpolation='nearest') +def test_mask_image_all(): + # Test behavior with an image that is entirely masked does not warn + data = np.full((2, 2), np.nan) + fig, ax = plt.subplots() + ax.imshow(data) + fig.canvas.draw_idle() # would emit a warning + + @image_comparison(['imshow_endianess.png'], remove_text=True) def test_imshow_endianess(): x = np.arange(10)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: