diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0292ccb64218..65f66e35c90e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5170,9 +5170,9 @@ def imshow(self, X, cmap=None, norm=None, aspect=None, shape : scalars (columns, rows), optional, default: None For raw buffer images - filternorm : scalar, optional, default: 1 - A parameter for the antigrain image resize filter. From the - antigrain documentation, if `filternorm` = 1, the filter + filternorm : bool, optional, default: True + A parameter for the antigrain image resize filter (see the + antigrain documentation). If *filternorm* is set, the filter normalizes integer values and corrects the rounding errors. It doesn't do anything with the source floating point values, it corrects only integers according to the rule of 1.0 which means diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index bb47d804699f..81357ecb2cc4 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -188,7 +188,7 @@ def __init__(self, ax, norm=None, interpolation=None, origin=None, - filternorm=1, + filternorm=True, filterrad=4.0, resample=False, **kwargs @@ -424,7 +424,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, _interpd_[self.get_interpolation()], self.get_resample(), 1.0, self.get_filternorm(), - self.get_filterrad() or 0.0) + self.get_filterrad()) # we are done with A_scaled now, remove from namespace # to be sure! @@ -459,7 +459,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, _interpd_[self.get_interpolation()], True, 1, self.get_filternorm(), - self.get_filterrad() or 0.0) + self.get_filterrad()) # we are done with the mask, delete from namespace to be sure! del mask # Agg updates the out_mask in place. If the pixel has @@ -492,7 +492,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, _image.resample( A, output, t, _interpd_[self.get_interpolation()], self.get_resample(), alpha, - self.get_filternorm(), self.get_filterrad() or 0.0) + self.get_filternorm(), self.get_filterrad()) # at this point output is either a 2D array of normed data # (of int or float) @@ -735,20 +735,17 @@ def get_resample(self): def set_filternorm(self, filternorm): """ - Set whether the resize filter norms the weights -- see - help for imshow + Set whether the resize filter normalizes the weights. - ACCEPTS: 0 or 1 - """ - if filternorm: - self._filternorm = 1 - else: - self._filternorm = 0 + See help for `~.Axes.imshow`. + .. ACCEPTS: bool + """ + self._filternorm = bool(filternorm) self.stale = True def get_filternorm(self): - """Return the filternorm setting.""" + """Return whether the resize filter normalizes the weights.""" return self._filternorm def set_filterrad(self, filterrad):