@@ -4988,82 +4988,117 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
4988
4988
origin = None , extent = None , shape = None , filternorm = 1 ,
4989
4989
filterrad = 4.0 , imlim = None , resample = None , url = None , ** kwargs ):
4990
4990
"""
4991
- Display an image on the axes .
4991
+ Display an image, i.e. data on a 2D regular raster .
4992
4992
4993
4993
Parameters
4994
4994
----------
4995
- X : array_like, shape (n, m) or (n, m, 3) or (n, m, 4)
4996
- Display the image in `X` to current axes. `X` may be an
4997
- array or a PIL image. If `X` is an array, it
4998
- can have the following shapes and types:
4995
+ X : array-like or PIL image
4996
+ The image data. Supported array shapes are:
4999
4997
5000
- - MxN -- values to be mapped (float or int)
5001
- - MxNx3 -- RGB (float or uint8)
5002
- - MxNx4 -- RGBA (float or uint8)
4998
+ - (M, N): an image with scalar data. The data is visualized
4999
+ using a colormap.
5000
+ - (M, N, 3): an image with RGB values (float or uint8).
5001
+ - (M, N, 4): an image with RGBA values (float or uint8), i.e.
5002
+ including transparency.
5003
5003
5004
- MxN arrays are mapped to colors based on the `norm` (mapping
5005
- scalar to scalar) and the `cmap` (mapping the normed scalar to
5006
- a color).
5004
+ The first two dimensions (M, N) define the rows and columns of
5005
+ the image.
5007
5006
5008
- Elements of RGB and RGBA arrays represent pixels of an MxN image.
5009
- All values should be in the range [0 .. 1] for floats or
5007
+ The RGB(A) values should be in the range [0 .. 1] for floats or
5010
5008
[0 .. 255] for integers. Out-of-range values will be clipped to
5011
5009
these bounds.
5012
5010
5013
- cmap : `~matplotlib.colors.Colormap`, optional, default: None
5014
- If None, default to rc `image.cmap` value. `cmap` is ignored
5015
- if `X` is 3-D, directly specifying RGB(A) values.
5011
+ cmap : str or `~matplotlib.colors.Colormap`, optional
5012
+ A Colormap instance or registered colormap name. The colormap
5013
+ maps scalar data to colors. It is ignored for RGB(A) data.
5014
+ Defaults to :rc:`image.cmap`.
5016
5015
5017
- aspect : ['auto' | 'equal' | scalar], optional, default: None
5018
- If 'auto', changes the image aspect ratio to match that of the
5019
- axes.
5016
+ aspect : {'equal', 'auto'} or float, optional
5017
+ Controls the aspect ratio of the axes. The aspect is of particular
5018
+ relevance for images since it may distort the image, i.e. pixel
5019
+ will not be square.
5020
5020
5021
- If 'equal', and `extent` is None, changes the axes aspect ratio to
5022
- match that of the image. If `extent` is not `None`, the axes
5023
- aspect ratio is changed to match that of the extent.
5021
+ This parameter is a shortcut for explicitly calling
5022
+ `.Axes.set_aspect`. See there for further details.
5024
5023
5025
- If None, default to rc ``image.aspect`` value.
5024
+ - 'equal': Ensures an aspect ratio of 1. Pixels will be square
5025
+ (unless pixel sizes are explicitly made non-square in data
5026
+ coordinates using *extent*).
5027
+ - 'auto': The axes is kept fixed and the aspect is adjusted so
5028
+ that the data fit in the axes. In general, this will result in
5029
+ non-square pixels.
5030
+
5031
+ Defaults to :rc:`image.aspect`.
5032
+
5033
+ interpolation : str, optional
5034
+ The interpolation method used. If *None*
5035
+ :rc:`image.interpolation` is used, which defaults to 'nearest'.
5026
5036
5027
- interpolation : string, optional, default: None
5028
- Acceptable values are 'none', 'nearest', 'bilinear', 'bicubic',
5037
+ Supported values are 'none', 'nearest', 'bilinear', 'bicubic',
5029
5038
'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser',
5030
5039
'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc',
5031
- 'lanczos'
5040
+ 'lanczos'.
5032
5041
5033
- If `interpolation` is None, default to rc `image.interpolation`.
5034
- See also the `filternorm` and `filterrad` parameters.
5035
- If `interpolation` is 'none', then no interpolation is performed
5042
+ If *interpolation* is 'none', then no interpolation is performed
5036
5043
on the Agg, ps and pdf backends. Other backends will fall back to
5037
5044
'nearest'.
5038
5045
5039
- norm : `~matplotlib.colors.Normalize`, optional, default: None
5040
- A `~matplotlib.colors.Normalize` instance is used to scale
5041
- a 2-D float `X` input to the (0, 1) range for input to the
5042
- `cmap`. If `norm` is None, use the default func:`normalize`.
5043
- If `norm` is an instance of `~matplotlib.colors.NoNorm`,
5044
- `X` must be an array of integers that index directly into
5045
- the lookup table of the `cmap`.
5046
+ See
5047
+ :doc:`/gallery/images_contours_and_fields/interpolation_methods`
5048
+ for an overview of the supported interpolation methods.
5046
5049
5047
- vmin, vmax : scalar, optional, default: None
5048
- `vmin` and `vmax` are used in conjunction with norm to normalize
5049
- luminance data. Note if you pass a `norm` instance, your
5050
- settings for `vmin` and `vmax` will be ignored.
5050
+ Some interpolation methods require an additional radius parameter,
5051
+ which can be set by *filterrad*. Additionally, the antigrain image
5052
+ resize filter is controlled by the parameter *filternorm*.
5051
5053
5052
- alpha : scalar, optional, default: None
5054
+ norm : `~matplotlib.colors.Normalize`, optional
5055
+ If scalar data are used, the Normalize instance scales the
5056
+ data values to the canonical colormap range [0,1] for mapping
5057
+ to colors. By default, the data range is mapped to the
5058
+ colorbar range using linear scaling. This parameter is ignored for
5059
+ RGB(A) data.
5060
+
5061
+ vmin, vmax : scalar, optional
5062
+ When using scalar data and no explicit *norm*, *vmin* and *vmax*
5063
+ define the data range that the colormap covers. By default,
5064
+ the colormap covers the complete value range of the supplied
5065
+ data. *vmin*, *vmax* are ignored if the *norm* parameter is used.
5066
+
5067
+ alpha : scalar, optional
5053
5068
The alpha blending value, between 0 (transparent) and 1 (opaque).
5054
- The ``alpha`` argument is ignored for RGBA input data.
5069
+ This parameter is ignored for RGBA input data.
5055
5070
5056
- origin : [ 'upper' | 'lower'] , optional, default: None
5071
+ origin : { 'upper', 'lower'} , optional
5057
5072
Place the [0,0] index of the array in the upper left or lower left
5058
- corner of the axes. If None, default to rc `image.origin`.
5073
+ corner of the axes. The convention 'upper' is typically used for
5074
+ matrices and images.
5075
+ If not given, :rc:`image.origin` is used, defaulting to 'upper'.
5076
+
5077
+ Note that the vertical axes points upward for 'lower'
5078
+ but downward for 'upper'.
5079
+
5080
+ extent : scalars (left, right, bottom, top), optional
5081
+ The bounding box in data coordinates that the image will fill.
5082
+ The image is stretched individually along x and y to fill the box.
5059
5083
5060
- extent : scalars (left, right, bottom, top), optional, default: None
5061
- The location, in data-coordinates, of the lower-left and
5062
- upper-right corners. If `None`, the image is positioned such that
5063
- the pixel centers fall on zero-based (row, column) indices.
5084
+ The default extent is determined by the following conditions.
5085
+ Pixels have unit size in data coordinates. Their centers are on
5086
+ integer coordinates, and their center coordinates range from 0 to
5087
+ columns-1 horizontally and from 0 to rows-1 vertically.
5088
+
5089
+ Note that the direction of the vertical axis and thus the default
5090
+ values for top and bottom depend on *origin*:
5091
+
5092
+ - For ``origin == 'upper'`` the default is
5093
+ ``(-0.5, numcols-0.5, numrows-0.5, -0.5)``.
5094
+ - For ``origin == 'lower'`` the default is
5095
+ ``(-0.5, numcols-0.5, -0.5, numrows-0.5)``.
5096
+
5097
+ See the example :doc:`/tutorials/intermediate/imshow_extent` for a
5098
+ more detailed description.
5064
5099
5065
5100
shape : scalars (columns, rows), optional, default: None
5066
- For raw buffer images
5101
+ For raw buffer images.
5067
5102
5068
5103
filternorm : bool, optional, default: True
5069
5104
A parameter for the antigrain image resize filter (see the
@@ -5074,17 +5109,26 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5074
5109
that any sum of pixel weights must be equal to 1.0. So, the
5075
5110
filter function must produce a graph of the proper shape.
5076
5111
5077
- filterrad : scalar , optional, default: 4.0
5112
+ filterrad : float > 0 , optional, default: 4.0
5078
5113
The filter radius for filters that have a radius parameter, i.e.
5079
- when interpolation is one of: 'sinc', 'lanczos' or 'blackman'
5114
+ when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
5115
+
5116
+ resample : bool, optional
5117
+ When *True*, use a full resampling method. When *False*, only
5118
+ resample when the output image is larger than the input image.
5119
+
5120
+ url : str, optional
5121
+ Set the url of the created `.AxesImage`. See `.Artist.set_url`.
5080
5122
5081
5123
Returns
5082
5124
-------
5083
5125
image : `~matplotlib.image.AxesImage`
5084
5126
5085
5127
Other Parameters
5086
5128
----------------
5087
- **kwargs : `~matplotlib.artist.Artist` properties.
5129
+ **kwargs : `~matplotlib.artist.Artist` properties
5130
+ These parameters are passed on to the constructor of the
5131
+ `.AxesImage` artist.
5088
5132
5089
5133
See also
5090
5134
--------
@@ -5096,7 +5140,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5096
5140
coordinates. In other words: the origin will coincide with the center
5097
5141
of pixel (0, 0).
5098
5142
5099
- Two typical representations are used for RGB images with an alpha
5143
+ There are two common representations for RGB images with an alpha
5100
5144
channel:
5101
5145
5102
5146
- Straight (unassociated) alpha: R, G, and B channels represent the
@@ -5122,8 +5166,6 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5122
5166
if im .get_clip_path () is None :
5123
5167
# image does not already have clipping set, clip to axes patch
5124
5168
im .set_clip_path (self .patch )
5125
- #if norm is None and shape is None:
5126
- # im.set_clim(vmin, vmax)
5127
5169
if vmin is not None or vmax is not None :
5128
5170
im .set_clim (vmin , vmax )
5129
5171
else :
@@ -7273,7 +7315,7 @@ def matshow(self, Z, **kwargs):
7273
7315
7274
7316
Parameters
7275
7317
----------
7276
- Z : array-like(N, M )
7318
+ Z : array-like(M, N )
7277
7319
The matrix to be displayed.
7278
7320
7279
7321
Returns
0 commit comments