@@ -5527,12 +5527,12 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5527
5527
5528
5528
The input may either be actual RGB(A) data, or 2D scalar data, which
5529
5529
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
5531
5531
``cmap='gray', vmin=0, vmax=255``.
5532
5532
5533
5533
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
5536
5536
not match the size of *X* (see
5537
5537
:doc:`/gallery/images_contours_and_fields/image_antialiasing`).
5538
5538
The resampling can be controlled via the *interpolation* parameter
@@ -5567,7 +5567,7 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5567
5567
5568
5568
This parameter is ignored if *X* is RGB(A).
5569
5569
5570
- aspect : {'equal', 'auto'} or float, default: :rc:`image.aspect`
5570
+ aspect : {'equal', 'auto'} or float or None , default: None
5571
5571
The aspect ratio of the Axes. This parameter is particularly
5572
5572
relevant for images since it determines whether data pixels are
5573
5573
square.
@@ -5582,6 +5582,11 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5582
5582
that the data fit in the Axes. In general, this will result in
5583
5583
non-square pixels.
5584
5584
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
+
5585
5590
interpolation : str, default: :rc:`image.interpolation`
5586
5591
The interpolation method used.
5587
5592
@@ -5715,16 +5720,20 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5715
5720
`~matplotlib.pyplot.imshow` expects RGB images adopting the straight
5716
5721
(unassociated) alpha representation.
5717
5722
"""
5718
- if aspect is None :
5719
- aspect = mpl .rcParams ['image.aspect' ]
5720
- self .set_aspect (aspect )
5721
5723
im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
5722
5724
interpolation = interpolation , origin = origin ,
5723
5725
extent = extent , filternorm = filternorm ,
5724
5726
filterrad = filterrad , resample = resample ,
5725
5727
interpolation_stage = interpolation_stage ,
5726
5728
** kwargs )
5727
5729
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
+
5728
5737
im .set_data (X )
5729
5738
im .set_alpha (alpha )
5730
5739
if im .get_clip_path () is None :
0 commit comments