diff --git a/lib/matplotlib/cm.py b/lib/matplotlib/cm.py index bdf3e1575653..b08b23798b55 100644 --- a/lib/matplotlib/cm.py +++ b/lib/matplotlib/cm.py @@ -375,3 +375,4 @@ def changed(self): for key in self.update_dict: self.update_dict[key] = True + self.stale = True diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index d34f98b4e45a..c0822b6f83b7 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -192,14 +192,6 @@ def _interpdr(self): def iterpnames(self): return interpolations_names - def set_cmap(self, cmap): - super(_ImageBase, self).set_cmap(cmap) - self.stale = True - - def set_norm(self, norm): - super(_ImageBase, self).set_norm(norm) - self.stale = True - def __str__(self): return "AxesImage(%g,%g;%gx%g)" % tuple(self.axes.bbox.bounds) @@ -357,58 +349,100 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, out_height = int(out_height_base) if not unsampled: - created_rgba_mask = False - if A.ndim not in (2, 3): raise ValueError("Invalid dimensions, got {}".format(A.shape)) if A.ndim == 2: - A = self.norm(A) - if A.dtype.kind == 'f': - # If the image is greyscale, convert to RGBA and - # use the extra channels for resizing the over, - # under, and bad pixels. This is needed because - # Agg's resampler is very aggressive about - # clipping to [0, 1] and we use out-of-bounds - # values to carry the over/under/bad information - rgba = np.empty((A.shape[0], A.shape[1], 4), dtype=A.dtype) - rgba[..., 0] = A # normalized data - # this is to work around spurious warnings coming - # out of masked arrays. - with np.errstate(invalid='ignore'): - rgba[..., 1] = np.where(A < 0, np.nan, 1) # under data - rgba[..., 2] = np.where(A > 1, np.nan, 1) # over data - # Have to invert mask, Agg knows what alpha means - # so if you put this in as 0 for 'good' points, they - # all get zeroed out - rgba[..., 3] = 1 - if A.mask.shape == A.shape: - # this is the case of a nontrivial mask - mask = np.where(A.mask, np.nan, 1) - else: - # this is the case that the mask is a - # numpy.bool_ of False - mask = A.mask - # ~A.mask # masked data - A = rgba - output = np.zeros((out_height, out_width, 4), - dtype=A.dtype) - alpha = 1.0 - created_rgba_mask = True + # if we are a 2D array, then we are running through the + # norm + colormap transformation. However, in general the + # input data is not going to match the size on the screen so we + # have to resample to the correct number of pixels + # need to + + # TODO slice input array first + inp_dtype = A.dtype + if inp_dtype.kind == 'f': + scaled_dtype = A.dtype + else: + scaled_dtype = np.float32 + # old versions of numpy do not work with `np.nammin` + # and `np.nanmax` as inputs + a_min = np.ma.min(A) + a_max = np.ma.max(A) + # scale the input data to [.1, .9]. The Agg + # interpolators clip to [0, 1] internally, use a + # smaller input scale to identify which of the + # interpolated points need to be should be flagged as + # over / under. + # This may introduce numeric instabilities in very broadly + # scaled data + A_scaled = np.empty(A.shape, dtype=scaled_dtype) + A_scaled[:] = A + A_scaled -= a_min + if a_min != a_max: + A_scaled /= ((a_max - a_min) / 0.8) + A_scaled += 0.1 + A_resampled = np.zeros((out_height, out_width), + dtype=A_scaled.dtype) + # resample the input data to the correct resolution and shape + _image.resample(A_scaled, A_resampled, + t, + _interpd_[self.get_interpolation()], + self.get_resample(), 1.0, + self.get_filternorm() or 0.0, + self.get_filterrad() or 0.0) + + # we are done with A_scaled now, remove from namespace + # to be sure! + del A_scaled + # un-scale the resampled data to approximately the + # original range things that interpolated to above / + # below the original min/max will still be above / + # below, but possibly clipped in the case of higher order + # interpolation + drastically changing data. + A_resampled -= 0.1 + if a_min != a_max: + A_resampled *= ((a_max - a_min) / 0.8) + A_resampled += a_min + # if using NoNorm, cast back to the original datatype + if isinstance(self.norm, mcolors.NoNorm): + A_resampled = A_resampled.astype(A.dtype) + + mask = np.empty(A.shape, dtype=np.float32) + if A.mask.shape == A.shape: + # this is the case of a nontrivial mask + mask[:] = np.where(A.mask, np.float32(np.nan), + np.float32(1)) else: - # colormap norms that output integers (ex NoNorm - # and BoundaryNorm) to RGBA space before - # interpolating. This is needed due to the - # Agg resampler only working on floats in the - # range [0, 1] and because interpolating indexes - # into an arbitrary LUT may be problematic. - # - # This falls back to interpolating in RGBA space which - # can produce it's own artifacts of colors not in the map - # showing up in the final image. - A = self.cmap(A, alpha=self.get_alpha(), bytes=True) - - if not created_rgba_mask: + mask[:] = 1 + + # we always have to interpolate the mask to account for + # non-affine transformations + out_mask = np.zeros((out_height, out_width), + dtype=mask.dtype) + _image.resample(mask, out_mask, + t, + _interpd_[self.get_interpolation()], + True, 1, + self.get_filternorm() or 0.0, + self.get_filterrad() or 0.0) + # 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 + # no image data it will not be updated (and still be 0 + # as we initialized it), if input data that would go + # into that output pixel than it will be `nan`, if all + # the input data for a pixel is good it will be 1, and + # if there is _some_ good data in that output pixel it + # will be between [0, 1] (such as a rotated image). + + out_alpha = np.array(out_mask) + out_mask = np.isnan(out_mask) + out_alpha[out_mask] = 1 + + # mask and run through the norm + output = self.norm(np.ma.masked_array(A_resampled, out_mask)) + else: # Always convert to RGBA, even if only RGB input if A.shape[2] == 3: A = _rgb_to_rgba(A) @@ -421,57 +455,27 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, if alpha is None: alpha = 1.0 - _image.resample( - A, output, t, _interpd_[self.get_interpolation()], - self.get_resample(), alpha, - self.get_filternorm() or 0.0, self.get_filterrad() or 0.0) - - if created_rgba_mask: - # Convert back to a masked greyscale array so - # colormapping works correctly - hid_output = output - # any pixel where the a masked pixel is included - # in the kernel (pulling this down from 1) needs to - # be masked in the output - if len(mask.shape) == 2: - out_mask = np.empty((out_height, out_width), - dtype=mask.dtype) - _image.resample(mask, out_mask, t, - _interpd_[self.get_interpolation()], - True, 1, - self.get_filternorm() or 0.0, - self.get_filterrad() or 0.0) - out_mask = np.isnan(out_mask) - else: - out_mask = mask - # we need to mask both pixels which came in as masked - # and the pixels that Agg is telling us to ignore (relavent - # to non-affine transforms) - # Use half alpha as the threshold for pixels to mask. - out_mask = out_mask | (hid_output[..., 3] < .5) - output = np.ma.masked_array( - hid_output[..., 0], - out_mask) - # 'unshare' the mask array to - # needed to suppress numpy warning - del out_mask - invalid_mask = ~output.mask * ~np.isnan(output.data) - # relabel under data. If any of the input data for - # the pixel has input out of the norm bounds, - output[np.isnan(hid_output[..., 1]) * invalid_mask] = -1 - # relabel over data - output[np.isnan(hid_output[..., 2]) * invalid_mask] = 2 + _image.resample( + A, output, t, _interpd_[self.get_interpolation()], + self.get_resample(), alpha, + self.get_filternorm() or 0.0, self.get_filterrad() or 0.0) + # at this point output is either a 2D array of normed data + # (of int or float) + # or an RGBA array of re-sampled input output = self.to_rgba(output, bytes=True, norm=False) + # output is now a correctly sized RGBA array of uint8 # Apply alpha *after* if the input was greyscale without a mask - if A.ndim == 2 or created_rgba_mask: + if A.ndim == 2: alpha = self.get_alpha() - if alpha is not None and alpha != 1.0: - alpha_channel = output[:, :, 3] - alpha_channel[:] = np.asarray( - np.asarray(alpha_channel, np.float32) * alpha, - np.uint8) + if alpha is None: + alpha = 1 + alpha_channel = output[:, :, 3] + alpha_channel[:] = np.asarray( + np.asarray(alpha_channel, np.float32) * out_alpha * alpha, + np.uint8) + else: if self._imcache is None: self._imcache = self.to_rgba(A, bytes=True, norm=(A.ndim == 2)) diff --git a/lib/matplotlib/tests/baseline_images/test_axes/imshow.pdf b/lib/matplotlib/tests/baseline_images/test_axes/imshow.pdf index 9f6c1ba4f54a..875868fff1e7 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/imshow.pdf and b/lib/matplotlib/tests/baseline_images/test_axes/imshow.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/imshow.png b/lib/matplotlib/tests/baseline_images/test_axes/imshow.png index db17406bcf32..c19c4e069b15 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/imshow.png and b/lib/matplotlib/tests/baseline_images/test_axes/imshow.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/imshow.svg b/lib/matplotlib/tests/baseline_images/test_axes/imshow.svg index 4dfd29b07c05..c1b02ae65bb4 100644 --- a/lib/matplotlib/tests/baseline_images/test_axes/imshow.svg +++ b/lib/matplotlib/tests/baseline_images/test_axes/imshow.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + - - - - - - - - +L 0 3.5 +" id="m06536c3ead" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - - - - + +L -3.5 0 +" id="m9813bbaa73" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + + + + + + + + + + + + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.pdf b/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.pdf index 834441d139dd..c33c7c4e29ca 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.pdf and b/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.png b/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.png index 83f77495efca..3f38834b9758 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.png and b/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg b/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg index 5fc1c49b7a26..cf1def0057fc 100644 --- a/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg +++ b/lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - - - - + + +L 0 3.5 +" id="mc1ef245d8f" style="stroke:#000000;stroke-width:0.8;"/> - - - - - - - - - + @@ -205,6 +54,7 @@ Q 39.453125 6.390625 43.28125 13.890625 Q 47.125 21.390625 47.125 36.375 Q 47.125 51.421875 43.28125 58.90625 Q 39.453125 66.40625 31.78125 66.40625 +z M 31.78125 74.21875 Q 44.046875 74.21875 50.515625 64.515625 Q 56.984375 54.828125 56.984375 36.375 @@ -214,22 +64,18 @@ Q 19.53125 -1.421875 13.0625 8.265625 Q 6.59375 17.96875 6.59375 36.375 Q 6.59375 54.828125 13.0625 64.515625 Q 19.53125 74.21875 31.78125 74.21875 +z " id="DejaVuSans-30"/> - + - - - - - - + - + @@ -257,23 +103,19 @@ Q 53.21875 48.921875 51.53125 44.890625 Q 49.859375 40.875 45.40625 35.40625 Q 44.1875 33.984375 37.640625 27.21875 Q 31.109375 20.453125 19.1875 8.296875 +z " id="DejaVuSans-32"/> - + - - - - - - + - + @@ -297,21 +139,16 @@ L 4.890625 26.703125 z " id="DejaVuSans-34"/> - + - - - - - - + - + @@ -326,6 +163,7 @@ Q 39.65625 6.390625 43.53125 10.953125 Q 47.40625 15.53125 47.40625 23.390625 Q 47.40625 31.296875 43.53125 35.828125 Q 39.65625 40.375 33.015625 40.375 +z M 52.59375 71.296875 L 52.59375 62.3125 Q 48.875 64.0625 45.09375 64.984375 @@ -344,23 +182,19 @@ Q 6.984375 53.65625 15.1875 63.9375 Q 23.390625 74.21875 37.203125 74.21875 Q 40.921875 74.21875 44.703125 73.484375 Q 48.484375 72.75 52.59375 71.296875 +z " id="DejaVuSans-36"/> - + - - - - - - + - + @@ -375,6 +209,7 @@ Q 38.8125 6.390625 42.859375 10.171875 Q 46.921875 13.96875 46.921875 20.515625 Q 46.921875 27.09375 42.890625 30.859375 Q 38.875 34.625 31.78125 34.625 +z M 21.921875 38.8125 Q 15.578125 40.375 12.03125 44.71875 Q 8.5 49.078125 8.5 55.328125 @@ -392,6 +227,7 @@ Q 19.734375 -1.421875 13.25 4.234375 Q 6.78125 9.90625 6.78125 20.515625 Q 6.78125 27.484375 10.78125 32.3125 Q 14.796875 37.15625 21.921875 38.8125 +z M 18.3125 54.390625 Q 18.3125 48.734375 21.84375 45.5625 Q 25.390625 42.390625 31.78125 42.390625 @@ -401,9 +237,10 @@ Q 45.3125 60.0625 41.71875 63.234375 Q 38.140625 66.40625 31.78125 66.40625 Q 25.390625 66.40625 21.84375 63.234375 Q 18.3125 60.0625 18.3125 54.390625 +z " id="DejaVuSans-38"/> - + @@ -412,341 +249,440 @@ Q 18.3125 60.0625 18.3125 54.390625 - - - - - - - - - + +L -3.5 0 +" id="m1594da3bf1" style="stroke:#000000;stroke-width:0.8;"/> - + - + - - - - - - + - + - + - - - - - - + - + - + - - - - - - + - + - + - - - - - - + - + - + + + + + + + + + + + + + + + + - - + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.pdf b/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.pdf index 6bf2a8f97aa8..f1cc042d6606 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.pdf and b/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.png b/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.png index 442b8ecb0702..c593b2163997 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.png and b/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.svg b/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.svg index d5de3e58a0d6..1d12107f0323 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/bbox_image_inverted.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + - - - - - - - - +L 0 3.5 +" id="m11605eaf61" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - - - - + +L -3.5 0 +" id="m279435e6ee" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + + + + + + + + + + + + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_clip.pdf b/lib/matplotlib/tests/baseline_images/test_image/image_clip.pdf index e3054449537f..63581cea0a06 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_clip.pdf and b/lib/matplotlib/tests/baseline_images/test_image/image_clip.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_clip.png b/lib/matplotlib/tests/baseline_images/test_image/image_clip.png index 106660776cb8..6a25e74d2987 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_clip.png and b/lib/matplotlib/tests/baseline_images/test_image/image_clip.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg b/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg index c30f9aed7575..776a0a7e2f90 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + - - - - - - - - +L 0 3.5 +" id="ma594e9199f" style="stroke:#000000;stroke-width:0.8;"/> - + - + - + + - + - + - + + + + + + + + + + + + + + + + - + - - - + + + + - - + + - + - + + + + + + + + + + + + - + - - - + + + + - - + + - + - + + + + + + + + + + + + + + + - + - - + + - + + - - + + - + - + + + + + + + + + + + + - + - - - + + + + - - - - - - - - - + +L -3.5 0 +" id="me5f59a1b3e" style="stroke:#000000;stroke-width:0.8;"/> - + - - - + + + + - + - + - + + + + + + + + + + + + + - + - - - + + + + - - + + - + - + + + + + + + + + + + + - + - - - + + + + - - + + - + - + + + + + + + + + + + + - + - - - + + + + - - + + - + - + + + + + + + + + + + + - + - - - + + + + + + + + + + + + + + + + - - + diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.pdf b/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.pdf index 0b315e71015e..894bd684fd9d 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.pdf and b/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.png b/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.png index cf5dc4f4b28c..8e23ab7b7b04 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.png and b/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.svg b/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.svg index 0fd258a316be..1cd39ab6346b 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/image_cliprect.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + +L 0 3.5 +" id="mc8f4e5d781" style="stroke:#000000;stroke-width:0.8;"/> - - - - - - - - - + @@ -84,6 +54,7 @@ Q 39.453125 6.390625 43.28125 13.890625 Q 47.125 21.390625 47.125 36.375 Q 47.125 51.421875 43.28125 58.90625 Q 39.453125 66.40625 31.78125 66.40625 +z M 31.78125 74.21875 Q 44.046875 74.21875 50.515625 64.515625 Q 56.984375 54.828125 56.984375 36.375 @@ -93,22 +64,18 @@ Q 19.53125 -1.421875 13.0625 8.265625 Q 6.59375 17.96875 6.59375 36.375 Q 6.59375 54.828125 13.0625 64.515625 Q 19.53125 74.21875 31.78125 74.21875 +z " id="DejaVuSans-30"/> - + - - - - - - + - + @@ -128,20 +95,15 @@ L 12.40625 0 z " id="DejaVuSans-31"/> - + - - - - - - + - + @@ -169,22 +131,18 @@ Q 53.21875 48.921875 51.53125 44.890625 Q 49.859375 40.875 45.40625 35.40625 Q 44.1875 33.984375 37.640625 27.21875 Q 31.109375 20.453125 19.1875 8.296875 +z " id="DejaVuSans-32"/> - + - - - - - - + - + @@ -220,22 +178,18 @@ Q 40.828125 74.21875 47.359375 69.109375 Q 53.90625 64.015625 53.90625 55.328125 Q 53.90625 49.265625 50.4375 45.09375 Q 46.96875 40.921875 40.578125 39.3125 +z " id="DejaVuSans-33"/> - + - - - - - - + - + @@ -259,20 +213,15 @@ L 4.890625 26.703125 z " id="DejaVuSans-34"/> - + - - - - - - + - + @@ -303,7 +252,7 @@ Q 14.890625 38.140625 10.796875 36.28125 z " id="DejaVuSans-35"/> - + @@ -311,129 +260,114 @@ z - - - - - - - - - + +L -3.5 0 +" id="m314c984111" style="stroke:#000000;stroke-width:0.8;"/> - + - + - - - - - - + - + - + - - - - - - + - + - + - - - - - - + - + - + - - - - - - + - + - + - - - - - - + - + - + + + + + + + + + + + + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.pdf b/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.pdf index 628dadb0a68c..85a87bddb14c 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.pdf and b/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.png b/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.png index f08646797f71..e7af5c29dd29 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.png and b/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.svg b/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.svg index 668c1bed033b..c08f2fa919e1 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/image_composite_background.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + - - - - - - - - +L 0 3.5 +" id="medc7ba5e5d" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - - - - + +L -3.5 0 +" id="mbb730fd48f" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + + + + + + + + + + + + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_interps.pdf b/lib/matplotlib/tests/baseline_images/test_image/image_interps.pdf index 6b3418faacd8..d4ee5a70e014 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_interps.pdf and b/lib/matplotlib/tests/baseline_images/test_image/image_interps.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_interps.png b/lib/matplotlib/tests/baseline_images/test_image/image_interps.png index 504d083f08d4..125d5e7b21b3 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/image_interps.png and b/lib/matplotlib/tests/baseline_images/test_image/image_interps.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/image_interps.svg b/lib/matplotlib/tests/baseline_images/test_image/image_interps.svg index 7e1df8c4bc5a..c02da4377e4f 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/image_interps.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/image_interps.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + - - - - - - - - +L 0 3.5 +" id="m69786bfced" style="stroke:#000000;stroke-width:0.8;"/> - + - + + - + + + - - - - - - + - + - + + - - + + + + - + - + - + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + - + + + - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - + - - - + + + - + + + @@ -203,154 +271,40 @@ z +L -3.5 0 +" id="m9f74638bbd" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + - + - + @@ -529,7 +487,27 @@ z - + + + + + + + + + + + + + - + @@ -638,205 +621,184 @@ z - - - - - - - - - - - - - - - + + - - - - - - - + + - + - - - + + + + + - - + + - + - + + + + + + + + + + + - + - - - + + + + + - - + + - + - + + + + + + + + + + + - + - - - + + + + + - - - - - - - + + - + - - - + + + - + + + - - - - - - - - - + + - + - - - - + + + + + + + - - - - - - - + + - + - - - + + + + + + - - - - - - - + + + + - + - - - - + + + + - - - - - - - + + - + - - - - + + + + - - - - - - - + + - + - + - + - + - + @@ -876,208 +839,207 @@ z + + + + + + + + + + + + - - - - - - - - - - - - - - - + + - - - - - - - + + - + - - - + + + + + - - + + - + - + + + + + + + + + + + - + - - - + + + + + - - + + - + + + + + + + + + - + + + - + - - - + + + + + - - - - - - - + + - + - - - + + + - + + + - - - - - - - - - + + - + - - - - + + + + + + + - - - - - - - + + - + - - - + + + + + + - - - - - - - + + + + - + - - - - + + + + - - - - - - - + + - + - - - - + + + + - - - - - - - + + - + - + - + - + - + @@ -1132,17 +1096,37 @@ z + + + + + + + + + + + + - - + + - - + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow.pdf b/lib/matplotlib/tests/baseline_images/test_image/imshow.pdf index deab892aa71d..4f1fb7db06cf 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/imshow.pdf and b/lib/matplotlib/tests/baseline_images/test_image/imshow.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow.png b/lib/matplotlib/tests/baseline_images/test_image/imshow.png index 051b17523a6a..34355b932da2 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/imshow.png and b/lib/matplotlib/tests/baseline_images/test_image/imshow.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow.svg b/lib/matplotlib/tests/baseline_images/test_image/imshow.svg index a87c2a96caaa..48e4f68aa0f1 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/imshow.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/imshow.svg @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - + + +L 0 3.5 +" id="m8b1ddf6bd1" style="stroke:#000000;stroke-width:0.8;"/> - - - - - - - - - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - - - - + +L -3.5 0 +" id="m516d1cc408" style="stroke:#000000;stroke-width:0.8;"/> - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + - - - - - - + - + + + + + + + + + + + + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow_flatfield.png b/lib/matplotlib/tests/baseline_images/test_image/imshow_flatfield.png new file mode 100644 index 000000000000..6c2656653bc1 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_image/imshow_flatfield.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.pdf b/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.pdf index ea5a6c877fda..561b9dc39538 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.pdf and b/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.png b/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.png index 07fba85d3c2d..da04fff7530c 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.png and b/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.svg b/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.svg index af53f58c3ab5..a04510e4c25c 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.svg @@ -18,167 +18,167 @@ z " style="fill:#ffffff;"/> - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + - - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/lib/matplotlib/tests/baseline_images/test_image/mask_image_over_under.png b/lib/matplotlib/tests/baseline_images/test_image/mask_image_over_under.png index 447494239a0f..a94b635b1c64 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/mask_image_over_under.png and b/lib/matplotlib/tests/baseline_images/test_image/mask_image_over_under.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.pdf b/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.pdf index d890b7fd9953..e40335e22503 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.pdf and b/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.svg b/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.svg index 1b9fcb533371..a4fda6a4e839 100644 --- a/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.svg +++ b/lib/matplotlib/tests/baseline_images/test_image/rasterize_10dpi.svg @@ -19,58 +19,58 @@ z - - - + + - - + - - - - + + + - - + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_image/rotate_image.png b/lib/matplotlib/tests/baseline_images/test_image/rotate_image.png index 322e8c00478f..f0edf0225890 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/rotate_image.png and b/lib/matplotlib/tests/baseline_images/test_image/rotate_image.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_image/zoom_and_clip_upper_origin.png b/lib/matplotlib/tests/baseline_images/test_image/zoom_and_clip_upper_origin.png index 0bccafb08442..f803b7a9d4de 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_image/zoom_and_clip_upper_origin.png and b/lib/matplotlib/tests/baseline_images/test_image/zoom_and_clip_upper_origin.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.pdf b/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.pdf index ef1f8932dab7..a8b20ed3ce98 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.pdf and b/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.png b/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.png index 44a2a5de14df..bc21b72c4f23 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.png and b/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.svg b/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.svg index b58f2c7e212c..bb01e6e785f0 100644 --- a/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.svg +++ b/lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.svg @@ -2,7 +2,7 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - + - - - + - + - - - + - + - - - + - + - - - + - + - - - + - + - - - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_pickle/multi_pickle.png b/lib/matplotlib/tests/baseline_images/test_pickle/multi_pickle.png index 8a42979c6b08..77abfe12edcb 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_pickle/multi_pickle.png and b/lib/matplotlib/tests/baseline_images/test_pickle/multi_pickle.png differ diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 7a0e8f326fc2..9c8c9f22c706 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -833,7 +833,7 @@ def test_nonfinite_limits(): @image_comparison(baseline_images=['imshow', 'imshow'], - remove_text=True) + remove_text=True, style='mpl20') def test_imshow(): # Create a NxN image N = 100 @@ -855,7 +855,7 @@ def test_imshow(): ax.imshow("r", data=data) -@image_comparison(baseline_images=['imshow_clip']) +@image_comparison(baseline_images=['imshow_clip'], style='mpl20') def test_imshow_clip(): # As originally reported by Gellule Xg diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 7bcc9d65d661..8ea9ae68adb8 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -34,7 +34,7 @@ needs_pillow = pytest.mark.xfail(not HAS_PIL, reason='Test requires Pillow') -@image_comparison(baseline_images=['image_interps']) +@image_comparison(baseline_images=['image_interps'], style='mpl20') def test_image_interps(): 'make the basic nearest, bilinear and bicubic interps' X = np.arange(100) @@ -248,7 +248,7 @@ def test_cursor_data(): assert z is None, "Did not get None, got %d" % z -@image_comparison(baseline_images=['image_clip']) +@image_comparison(baseline_images=['image_clip'], style='mpl20') def test_image_clip(): d = [[1, 2], [3, 4]] @@ -258,7 +258,7 @@ def test_image_clip(): im.set_clip_path(patch) -@image_comparison(baseline_images=['image_cliprect']) +@image_comparison(baseline_images=['image_cliprect'], style='mpl20') def test_image_cliprect(): import matplotlib.patches as patches @@ -271,7 +271,8 @@ def test_image_cliprect(): rect = patches.Rectangle(xy=(1,1), width=2, height=2, transform=im.axes.transData) im.set_clip_path(rect) -@image_comparison(baseline_images=['imshow'], remove_text=True) + +@image_comparison(baseline_images=['imshow'], remove_text=True, style='mpl20') def test_imshow(): import numpy as np import matplotlib.pyplot as plt @@ -334,7 +335,10 @@ def test_image_edges(): assert g != 100, 'Expected a non-green edge - but sadly, it was.' -@image_comparison(baseline_images=['image_composite_background'], remove_text=True) + +@image_comparison(baseline_images=['image_composite_background'], + remove_text=True, + style='mpl20') def test_image_composite_background(): fig = plt.figure() ax = fig.add_subplot(111) @@ -344,7 +348,9 @@ def test_image_composite_background(): ax.set_facecolor((1, 0, 0, 0.5)) ax.set_xlim([0, 12]) -@image_comparison(baseline_images=['image_composite_alpha'], remove_text=True) + +@image_comparison(baseline_images=['image_composite_alpha'], + remove_text=True) def test_image_composite_alpha(): """ Tests that the alpha value is recognized and correctly applied in the @@ -370,7 +376,9 @@ def test_image_composite_alpha(): ax.set_ylim([5, 0]) -@image_comparison(baseline_images=['rasterize_10dpi'], extensions=['pdf','svg'], remove_text=True) +@image_comparison(baseline_images=['rasterize_10dpi'], + extensions=['pdf', 'svg'], + remove_text=True, style='mpl20') def test_rasterize_dpi(): # This test should check rasterized rendering with high output resolution. # It plots a rasterized line and a normal image with implot. So it will catch @@ -403,7 +411,8 @@ def test_rasterize_dpi(): rcParams['savefig.dpi'] = 10 -@image_comparison(baseline_images=['bbox_image_inverted'], remove_text=True) +@image_comparison(baseline_images=['bbox_image_inverted'], remove_text=True, + style='mpl20') def test_bbox_image_inverted(): # This is just used to produce an image to feed to BboxImage image = np.arange(100).reshape((10, 10)) @@ -449,7 +458,8 @@ def test_get_window_extent_for_AxisImage(): @image_comparison(baseline_images=['zoom_and_clip_upper_origin'], remove_text=True, - extensions=['png']) + extensions=['png'], + style='mpl20') def test_zoom_and_clip_upper_origin(): image = np.arange(100) image = image.reshape((10, 10)) @@ -727,7 +737,7 @@ def test_imshow_endianess(): @image_comparison(baseline_images=['imshow_masked_interpolation'], - remove_text=True, style='default') + remove_text=True, style='mpl20') def test_imshow_masked_interpolation(): cm = copy(plt.get_cmap('viridis')) @@ -742,7 +752,8 @@ def test_imshow_masked_interpolation(): data = np.arange(N*N, dtype='float').reshape(N, N) data[5, 5] = -1 - + # This will cause crazy ringing for the higher-order + # interpolations data[15, 5] = 1e5 # data[3, 3] = np.nan @@ -755,6 +766,7 @@ def test_imshow_masked_interpolation(): data = np.ma.masked_array(data, mask) fig, ax_grid = plt.subplots(3, 6) + for interp, ax in zip(sorted(mimage._interpd_), ax_grid.ravel()): ax.set_title(interp) ax.imshow(data, norm=n, cmap=cm, interpolation=interp) @@ -768,6 +780,15 @@ def test_imshow_no_warn_invalid(): assert len(warns) == 0 +@image_comparison(baseline_images=['imshow_flatfield'], + remove_text=True, style='mpl20', + extensions=['png']) +def test_imshow_flatfield(): + fig, ax = plt.subplots() + im = ax.imshow(np.ones((5, 5))) + im.set_clim(.5, 1.5) + + def test_empty_imshow(): fig, ax = plt.subplots() im = ax.imshow([[]]) diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py index 2a024ea5be94..9b8a4379cb60 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -27,7 +27,8 @@ def test_patheffect1(): ax1.grid(True, linestyle="-", path_effects=pe) -@image_comparison(baseline_images=['patheffect2'], remove_text=True) +@image_comparison(baseline_images=['patheffect2'], remove_text=True, + style='mpl20') def test_patheffect2(): ax2 = plt.subplot(111) diff --git a/lib/matplotlib/tests/test_pickle.py b/lib/matplotlib/tests/test_pickle.py index de3b30cb5966..2046013d58b8 100644 --- a/lib/matplotlib/tests/test_pickle.py +++ b/lib/matplotlib/tests/test_pickle.py @@ -42,7 +42,8 @@ def test_simple(): @image_comparison(baseline_images=['multi_pickle'], - extensions=['png'], remove_text=True) + extensions=['png'], remove_text=True, + style='mpl20') def test_complete(): fig = plt.figure('Figure with a label?', figsize=(10, 6)) diff --git a/lib/matplotlib/tests/test_png.py b/lib/matplotlib/tests/test_png.py index 5dc3155f11e0..9047eed846c7 100644 --- a/lib/matplotlib/tests/test_png.py +++ b/lib/matplotlib/tests/test_png.py @@ -17,7 +17,7 @@ @image_comparison(baseline_images=['pngsuite'], extensions=['png'], - tol=0.02 if on_win else 0) + tol=0.03) def test_pngsuite(): dirname = os.path.join( os.path.dirname(__file__), diff --git a/lib/mpl_toolkits/tests/baseline_images/test_axes_grid/imagegrid_cbar_mode.png b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid/imagegrid_cbar_mode.png index f083d81a31a1..a42548f9f6cd 100644 Binary files a/lib/mpl_toolkits/tests/baseline_images/test_axes_grid/imagegrid_cbar_mode.png and b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid/imagegrid_cbar_mode.png differ diff --git a/lib/mpl_toolkits/tests/test_axes_grid.py b/lib/mpl_toolkits/tests/test_axes_grid.py index 480bf69db63d..55ebb6c1cae7 100644 --- a/lib/mpl_toolkits/tests/test_axes_grid.py +++ b/lib/mpl_toolkits/tests/test_axes_grid.py @@ -7,7 +7,8 @@ @image_comparison(baseline_images=['imagegrid_cbar_mode'], extensions=['png'], - remove_text=True) + remove_text=True, + style='mpl20') def test_imagegrid_cbar_mode_edge(): X, Y = np.meshgrid(np.linspace(0, 6, 30), np.linspace(0, 6, 30)) arr = np.sin(X) * np.cos(Y) + 1j*(np.sin(3*Y) * np.cos(Y/2.))