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