8000 Apply suggestions from code review · matplotlib/matplotlib@bd64bfc · GitHub
[go: up one dir, main page]

Skip to content

Commit bd64bfc

Browse files
jklymaktimhoffm
andauthored
Apply suggestions from code review
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent d0e3ce8 commit bd64bfc

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
imshow *interpolation_stage* default changed to 'auto'
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1+
``imshow`` *interpolation_stage* default changed to 'auto'
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
The *interpolation_stage* keyword argument `~.Axes.imshow` has a new default
4+
The *interpolation_stage* parameter of `~.Axes.imshow` has a new default
55
value 'auto'. For images that are up-sampled less than a factor of
66
three or down-sampled, image interpolation will occur in 'rgba' space. For images
7-
that are up-sampled by more than a factor of 3, then image interpolation occurs
7+
that are up-sampled by a factor of 3 or more, then image interpolation occurs
88
in 'data' space.
99

1010
The previous default was 'data', so down-sampled images may change subtly with
1111
the new default. However, the new default also avoids floating point artifacts
1212
at sharp boundaries in a colormap when down-sampling.
1313

14-
The previous behavior can achieved by changing :rc:`image.interpolation_stage`.
14+
The previous behavior can achieved by setting the *interpolation_stage* parameter
15+
or :rc:`image.interpolation_stage` to 'data'.
1516

1617
imshow default *interpolation* changed to 'auto'
1718
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1819

19-
The *interpolation* keyword argument `~.Axes.imshow` has a new default
20+
The *interpolation* parameter of `~.Axes.imshow` has a new default
2021
value 'auto', changed from 'antialiased', for consistency with *interpolation_stage*
21-
and because the interpolation is only anti-aliasing during down-sampling. The
22-
'antialiased' string still works, and behaves exactly the same as 'auto'.
22+
and because the interpolation is only anti-aliasing during down-sampling. Passing
23+
'antialiased' still works, and behaves exactly the same as 'auto', but is discouraged.

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5833,13 +5833,17 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
58335833
resize filter is controlled by the parameter *filternorm*.
58345834
58355835
interpolation_stage : {'auto', 'data', 'rgba'}, default: 'auto'
5836-
If 'data', interpolation is carried out on the data provided by the user,
5837-
useful if interpolating between pixels during upsampling.
5838-
If 'rgba', the interpolation is carried out in RGBA-space after the
5839-
color-mapping has been applied, useful if downsampling and combining
5840-
pixels visually. The default 'auto' is appropriate for most
5841-
applications where 'rgba' is used when downsampling, or upsampling at a
5842-
rate less than 3, and 'data' is used when upsampling at a higher rate.
5836+
Supported values:
5837+
5838+
- 'data': Interpolation is carried out on the data provided by the user
5839+
This is useful if interpolating between pixels during upsampling.
5840+
- 'rgba': The interpolation is carried out in RGBA-space after the
5841+
color-mapping has been applied. This is useful if downsampling and
5842+
combining pixels visually.
5843+
- 'auto': Select a suitable interpolation stage automatically. This uses
5844+
'rgba' when downsampling, or upsampling at a rate less than 3, and
5845+
'data' when upsampling at a higher rate.
5846+
58435847
See :doc:`/gallery/images_contours_and_fields/image_antialiasing` for
58445848
a discussion of image antialiasing.
58455849

lib/matplotlib/tests/test_png.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def test_pngsuite():
2020
if data.ndim == 2:
2121
# keep grayscale images gray
2222
cmap = cm.gray
23-
# use the old default data interpolation stage
23+
# Using the old default data interpolation stage lets us
24+
# continue to use the existing reference image
2425
plt.imshow(data, extent=(i, i + 1, 0, 1), cmap=cmap,
2526
interpolation_stage='data')
2627

0 commit comments

Comments
 (0)
0