@@ -5530,12 +5530,12 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
55305530
55315531 The input may either be actual RGB(A) data, or 2D scalar data, which
55325532 will be rendered as a pseudocolor image. For displaying a grayscale
5533- image set up the colormapping using the parameters
5533+ image, set up the colormapping using the parameters
55345534 ``cmap='gray', vmin=0, vmax=255``.
55355535
55365536 The number of pixels used to render an image is set by the Axes size
5537- and the *dpi* of the figure . This can lead to aliasing artifacts when
5538- the image is resampled because the displayed image size will usually
5537+ and the figure *dpi*. This can lead to aliasing artifacts when
5538+ the image is resampled, because the displayed image size will usually
55395539 not match the size of *X* (see
55405540 :doc:`/gallery/images_contours_and_fields/image_antialiasing`).
55415541 The resampling can be controlled via the *interpolation* parameter
@@ -5570,7 +5570,7 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
55705570
55715571 This parameter is ignored if *X* is RGB(A).
55725572
5573- aspect : {'equal', 'auto'} or float, default: :rc:`image.aspect`
5573+ aspect : {'equal', 'auto'} or float or None , default: None
55745574 The aspect ratio of the Axes. This parameter is particularly
55755575 relevant for images since it determines whether data pixels are
55765576 square.
@@ -5585,6 +5585,11 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
55855585 that the data fit in the Axes. In general, this will result in
55865586 non-square pixels.
55875587
5588+ Normally, None (the default) means to use :rc:`image.aspect`. However, if
5589+ the image uses a transform that does not contain the axes data transform,
5590+ then None means to not modify the axes aspect at all (in that case, directly
5591+ call `.Axes.set_aspect` if desired).
5592+
55885593 interpolation : str, default: :rc:`image.interpolation`
55895594 The interpolation method used.
55905595
@@ -5718,16 +5723,20 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
57185723 `~matplotlib.pyplot.imshow` expects RGB images adopting the straight
57195724 (unassociated) alpha representation.
57205725 """
5721- if aspect is None :
5722- aspect = mpl .rcParams ['image.aspect' ]
5723- self .set_aspect (aspect )
57245726 im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
57255727 interpolation = interpolation , origin = origin ,
57265728 extent = extent , filternorm = filternorm ,
57275729 filterrad = filterrad , resample = resample ,
57285730 interpolation_stage = interpolation_stage ,
57295731 ** kwargs )
57305732
5733+ if aspect is None and not (
5734+ im .is_transform_set ()
5735+ and not im .get_transform ().contains_branch (self .transData )):
5736+ aspect = mpl .rcParams ['image.aspect' ]
5737+ if aspect is not None :
5738+ self .set_aspect (aspect )
5739+
57315740 im .set_data (X )
57325741 im .set_alpha (alpha )
57335742 if im .get_clip_path () is None :
0 commit comments