@@ -5530,12 +5530,12 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5530
5530
5531
5531
The input may either be actual RGB(A) data, or 2D scalar data, which
5532
5532
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
5534
5534
``cmap='gray', vmin=0, vmax=255``.
5535
5535
5536
5536
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
5539
5539
not match the size of *X* (see
5540
5540
:doc:`/gallery/images_contours_and_fields/image_antialiasing`).
5541
5541
The resampling can be controlled via the *interpolation* parameter
@@ -5570,7 +5570,7 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5570
5570
5571
5571
This parameter is ignored if *X* is RGB(A).
5572
5572
5573
- aspect : {'equal', 'auto'} or float, default: :rc:`image.aspect`
5573
+ aspect : {'equal', 'auto'} or float or None , default: None
5574
5574
The aspect ratio of the Axes. This parameter is particularly
5575
5575
relevant for images since it determines whether data pixels are
5576
5576
square.
@@ -5585,6 +5585,11 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5585
5585
that the data fit in the Axes. In general, this will result in
5586
5586
non-square pixels.
5587
5587
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
+
5588
5593
interpolation : str, default: :rc:`image.interpolation`
5589
5594
The interpolation method used.
5590
5595
@@ -5718,16 +5723,20 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5718
5723
`~matplotlib.pyplot.imshow` expects RGB images adopting the straight
5719
5724
(unassociated) alpha representation.
5720
5725
"""
5721
- if aspect is None :
5722
- aspect = mpl .rcParams ['image.aspect' ]
5723
- self .set_aspect (aspect )
5724
5726
im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
5725
5727
interpolation = interpolation , origin = origin ,
5726
5728
extent = extent , filternorm = filternorm ,
5727
5729
filterrad = filterrad , resample = resample ,
5728
5730
interpolation_stage = interpolation_stage ,
5729
5731
** kwargs )
5730
5732
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
+
5731
5740
im .set_data (X )
5732
5741
im .set_alpha (alpha )
5733
5742
if im .get_clip_path () is None :
0 commit comments