From d9dad877d8bf841f6b26a2c29bd364a362b700f0 Mon Sep 17 00:00:00 2001 From: Siddharth Karmokar <155292670+SiddharthKarmokar@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:51:10 +0000 Subject: [PATCH 1/2] Update antialiased default to auto and fix documentation errors --- .../images_contours_and_fields/image_antialiasing.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/image_antialiasing.py b/galleries/examples/images_contours_and_fields/image_antialiasing.py index 7f223f6998f2..cfa3c96a4823 100644 --- a/galleries/examples/images_contours_and_fields/image_antialiasing.py +++ b/galleries/examples/images_contours_and_fields/image_antialiasing.py @@ -63,7 +63,7 @@ # # ``interpolation_stage='data'``: Data -> Interpolate/Resample -> Normalize -> RGBA # -# For both keyword arguments, Matplotlib has a default "antialiased", that is +# For both keyword arguments, Matplotlib has a default "auto", that is # recommended for most situations, and is described below. Note that this # default behaves differently if the image is being down- or up-sampled, as # described below. @@ -166,16 +166,19 @@ # %% # A final example shows the desirability of performing the anti-aliasing at the # RGBA stage when using non-trivial interpolation kernels. In the following, -# the data in the upper 100 rows is exactly 0.0, and data in the inner circle +# the data in the outer circle is exactly 0.0, and data in the inner circle # is exactly 2.0. If we perform the *interpolation_stage* in 'data' space and # use an anti-aliasing filter (first panel), then floating point imprecision # makes some of the data values just a bit less than zero or a bit more than # 2.0, and they get assigned the under- or over- colors. This can be avoided if -# you do not use an anti-aliasing filter (*interpolation* set set to +# you do not use an anti-aliasing filter (*interpolation* set to # 'nearest'), however, that makes the part of the data susceptible to Moiré # patterns much worse (second panel). Therefore, we recommend the default # *interpolation* of 'hanning'/'auto', and *interpolation_stage* of # 'rgba'/'auto' for most down-sampling situations (last panel). +# In this example, the data values are clipped at the edges of the color range. +# The interpolation uses the 'nearest' method, and as a result, no +# floating-point imprecision is visible in the first panel. a = alarge + 1 cmap = plt.get_cmap('RdBu_r') From 67f55f23b070ad89d7da40cfce3e2ec440563d61 Mon Sep 17 00:00:00 2001 From: Siddharth Karmokar <155292670+SiddharthKarmokar@users.noreply.github.com> Date: Tue, 4 Feb 2025 16:48:14 +0000 Subject: [PATCH 2/2] update image_antialiasing example document to reflect rcParam behavior --- .../images_contours_and_fields/image_antialiasing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/image_antialiasing.py b/galleries/examples/images_contours_and_fields/image_antialiasing.py index cfa3c96a4823..1a9c159e03ab 100644 --- a/galleries/examples/images_contours_and_fields/image_antialiasing.py +++ b/galleries/examples/images_contours_and_fields/image_antialiasing.py @@ -63,10 +63,10 @@ # # ``interpolation_stage='data'``: Data -> Interpolate/Resample -> Normalize -> RGBA # -# For both keyword arguments, Matplotlib has a default "auto", that is -# recommended for most situations, and is described below. Note that this -# default behaves differently if the image is being down- or up-sampled, as -# described below. +# For both keyword arguments, Matplotlib uses a default value of "auto" as +# specified by the rcParam, which is recommended for most situations. +# This default behavior is explained below. Note that the behavior may differ if the +# image is being down- or up-sampled, as outlined below. # # Down-sampling and modest up-sampling # ====================================