Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a88a70

Browse files
committed
DOC: expand section on image interpolation
1 parent 08a8499 commit 4a88a70

1 file changed

Lines changed: 76 additions & 13 deletions

File tree

doc/users/dflt_style_changes.rst

Lines changed: 76 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ TeX backend is used (i.e. ``text.usetex`` is ``True``).
502502
import matplotlib as mpl
503503

504504
mpl.rcParams['mathtext.fontset'] = 'cm'
505+
mpl.rcParams['mathtext.rm'] = 'serif'
505506

506507
fig, ax = plt.subplots(tight_layout=True, figsize=(3, 3))
507508

@@ -526,10 +527,13 @@ TeX backend is used (i.e. ``text.usetex`` is ``True``).
526527
To revert to the old behavior set the::
527528

528529
mpl.rcParams['mathtext.fontset'] = 'cm'
530+
mpl.rcParams['mathtext.rm'] = 'serif'
529531

530532
or by setting::
531533

532534
mathetxt.fontset: cm
535+
mathtext.rm : serif
536+
533537

534538
in your :file:`matplotlibrc` file.
535539

@@ -607,6 +611,78 @@ or by setting::
607611

608612
in your :file:`matplotlibrc` file.
609613

614+
Image
615+
=====
616+
617+
Interpolation
618+
-------------
619+
620+
The default interpolation method for `~matplotlib.axes.Axes.imshow` is now
621+
``'nearest'`` and by default resamples the data to both up and down sample
622+
then input before color mapping.
623+
624+
625+
.. plot::
626+
627+
import matplotlib.pyplot as plt
628+
import matplotlib as mpl
629+
import numpy as np
630+
631+
632+
def demo(ax, rcparams, title):
633+
np.random.seed(2)
634+
A = np.random.rand(5, 5)
635+
636+
with mpl.rc_context(rc=rcparams):
637+
ax.imshow(A)
638+
ax.set_title(title)
639+
640+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3), tight_layout=True)
641+
642+
classic_rcparams = {'image.interpolation': 'bilinear',
643+
'image.resample': False}
644+
645+
demo(ax1, classic_rcparams, 'classic')
646+
demo(ax2, {}, 'v2.0')
647+
648+
The default value for the rcParam ``image.resample`` is now ``True``.
649+
This will apply interpolation for both upsampling and downsampling
650+
of an image. ``image.interpolation``, is now ``nearest``.
651+
652+
Previously, the input data was normalized, then color mapped, and the
653+
resampled to the resolution required for the screen. This means that
654+
the final resampling was being done in color space. Because the color
655+
maps are not always linear in RGB space this can result in colors not
656+
in the color map appearing in the final image. This bug was addressed
657+
by an almost complete overhaul of how the image handling code works.
658+
The input data is now normalized, then resampled to the correct
659+
resolution (in scaled dataspace), and then finally color mapped to
660+
RGBA space which prevents any colors not in the color map from
661+
appearing in the final image (if your viewer subsequently resamples
662+
the image the artifact may reappear).
663+
664+
To restore the previous behavior set::
665+
666+
mpl.rcParams['image.interpolation'] = 'bilinear'
667+
mpl.rcParams['image.resample'] = False
668+
669+
or set::
670+
671+
image.interpolation : bilinear # see help(imshow) for options
672+
image.resample : False
673+
674+
in your :file:`matplotlibrc` file.
675+
676+
677+
Shading
678+
-------
679+
680+
- The default shading mode for light source shading, in
681+
``matplotlib.colors.LightSource.shade``, is now ``overlay``.
682+
Formerly, it was ``hsv``.
683+
684+
685+
610686

611687
TEMPORARY NOTES TOM IS KEEPING IN THE SOURCE SO THEY DO NOT GET LOST
612688
====================================================================
@@ -643,19 +719,6 @@ Plot layout
643719
- By default, caps on the ends of errorbars are not present. Use the
644720
rcParam ``errorbar.capsize`` to control this.
645721

646-
Images
647-
======
648-
649-
- The default mode for image interpolation, in the rcParam
650-
``image.interpolation``, is now ``nearest``.
651-
652-
- The default shading mode for light source shading, in
653-
``matplotlib.colors.LightSource.shade``, is now ``overlay``.
654-
Formerly, it was ``hsv``.
655-
656-
- The default value for the rcParam ``image.resample`` is now
657-
``True``. This will apply interpolation for both upsampling and
658-
downsampling of an image.
659722

660723

661724
Dates

0 commit comments

Comments
 (0)