diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 50fdcb2c695b..de7e5018125f 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -394,8 +394,10 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, A_scaled = np.empty(A.shape, dtype=scaled_dtype) A_scaled[:] = A A_scaled -= a_min - a_min = a_min.astype(scaled_dtype) - a_max = a_max.astype(scaled_dtype) + # a_min and a_max might be ndarray subclasses so use + # asscalar to ensure they are scalars to avoid errors + a_min = np.asscalar(a_min.astype(scaled_dtype)) + a_max = np.asscalar(a_max.astype(scaled_dtype)) if a_min != a_max: A_scaled /= ((a_max - a_min) / 0.8)