diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index bf49e34397dc..a06bee6fc070 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -107,7 +107,7 @@ def _sanitize_extrema(ex): if ex is None: return ex try: - ret = np.asscalar(ex) + ret = ex.item() except AttributeError: ret = float(ex) return ret diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index fe22bffc0e3f..54a670288ebc 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -411,9 +411,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, A_scaled -= a_min # a_min and a_max might be ndarray subclasses so use - # asscalar to avoid errors - a_min = np.asscalar(a_min.astype(scaled_dtype)) - a_max = np.asscalar(a_max.astype(scaled_dtype)) + # item to avoid errors + a_min = a_min.astype(scaled_dtype).item() + a_max = a_max.astype(scaled_dtype).item() if a_min != a_max: A_scaled /= ((a_max - a_min) / 0.8)