@@ -5527,12 +5527,12 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
55275527
55285528 The input may either be actual RGB(A) data, or 2D scalar data, which
55295529 will be rendered as a pseudocolor image. For displaying a grayscale
5530- image set up the colormapping using the parameters
5530+ image, set up the colormapping using the parameters
55315531 ``cmap='gray', vmin=0, vmax=255``.
55325532
55335533 The number of pixels used to render an image is set by the Axes size
5534- and the *dpi* of the figure . This can lead to aliasing artifacts when
5535- the image is resampled because the displayed image size will usually
5534+ and the figure *dpi*. This can lead to aliasing artifacts when
5535+ the image is resampled, because the displayed image size will usually
55365536 not match the size of *X* (see
55375537 :doc:`/gallery/images_contours_and_fields/image_antialiasing`).
55385538 The resampling can be controlled via the *interpolation* parameter
@@ -5567,7 +5567,7 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
55675567
55685568 This parameter is ignored if *X* is RGB(A).
55695569
5570- aspect : {'equal', 'auto'} or float, default: :rc:`image.aspect`
5570+ aspect : {'equal', 'auto'} or float or None , default: None
55715571 The aspect ratio of the Axes. This parameter is particularly
55725572 relevant for images since it determines whether data pixels are
55735573 square.
@@ -5582,6 +5582,11 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
55825582 that the data fit in the Axes. In general, this will result in
55835583 non-square pixels.
55845584
5585+ Normally, None (the default) means to use :rc:`image.aspect`. However, if
5586+ the image uses a transform that does not contain the axes data transform,
5587+ then None means to not modify the axes aspect at all (in that case, directly
5588+ call `.Axes.set_aspect` if desired).
5589+
55855590 interpolation : str, default: :rc:`image.interpolation`
55865591 The interpolation method used.
55875592
@@ -5715,16 +5720,20 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
57155720 `~matplotlib.pyplot.imshow` expects RGB images adopting the straight
57165721 (unassociated) alpha representation.
57175722 """
5718- if aspect is None :
5719- aspect = mpl .rcParams ['image.aspect' ]
5720- self .set_aspect (aspect )
57215723 im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
57225724 interpolation = interpolation , origin = origin ,
57235725 extent = extent , filternorm = filternorm ,
57245726 filterrad = filterrad , resample = resample ,
57255727 interpolation_stage = interpolation_stage ,
57265728 ** kwargs )
57275729
5730+ if aspect is None and not (
5731+ im .is_transform_set ()
5732+ and not im .get_transform ().contains_branch (self .transData )):
5733+ aspect = mpl .rcParams ['image.aspect' ]
5734+ if aspect is not None :
5735+ self .set_aspect (aspect )
5736+
57285737 im .set_data (X )
57295738 im .set_alpha (alpha )
57305739 if im .get_clip_path () is None :
0 commit comments