Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c958a8

Browse files
committed
Improve docstring of Axes.imshow
1 parente22a16a commit7c958a8

File tree

1 file changed

+88
-56
lines changed

1 file changed

+88
-56
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 88 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4988,82 +4988,107 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
49884988
origin=None,extent=None,shape=None,filternorm=1,
49894989
filterrad=4.0,imlim=None,resample=None,url=None,**kwargs):
49904990
"""
4991-
Display an imageonthe axes.
4991+
Display an image, i.e. dataona 2D regular raster.
49924992
49934993
Parameters
49944994
----------
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:
49994997
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.
50035003
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.
50075006
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
50105008
[0 .. 255] for integers. Out-of-range values will be clipped to
50115009
these bounds.
50125010
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`.
50165015
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+
would not be square.
50205020
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 just a shortcut for explicitly calling
5022+
`.Axes.set_aspect`. See there for further details.
50245023
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`.
50265032
5027-
interpolation :string, optional, default: None
5028-
Acceptable values are 'none', 'nearest', 'bilinear', 'bicubic',
5033+
interpolation :str, optional
5034+
Supported values are 'none', 'nearest', 'bilinear', 'bicubic',
50295035
'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser',
50305036
'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc',
5031-
'lanczos'
5037+
'lanczos'.
5038+
5039+
Defaults to :rc:`image.interpolation`.
50325040
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
5041+
See also the *filternorm* and *filterrad* parameters.
5042+
If *interpolation* is 'none', then no interpolation is performed
50365043
on the Agg, ps and pdf backends. Other backends will fall back to
50375044
'nearest'.
50385045
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+
norm : `~matplotlib.colors.Normalize`, optional
5047+
If scalar data is used, the Normalize instance scales the
5048+
data values to the canonical colormap range [0,1] for mapping
5049+
to colors. By default, the data range is mapped to the
5050+
colorbar range using linear scaling. This parameter is ignored for
5051+
RGB(A) data.
50465052
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.
5053+
vmin, vmax : scalar, optional
5054+
When using scalar data and no explicit *norm*, *vmin* and *vmax*
5055+
define the data range that the colormap covers. By default,
5056+
the colormap covers the complete value range of the supplied
5057+
data. *vmin*, *vmax* are ignored if the *norm* parameter is used.
50515058
5052-
alpha : scalar, optional, default: None
5059+
alpha : scalar, optional
50535060
The alpha blending value, between 0 (transparent) and 1 (opaque).
5054-
The ``alpha`` argument is ignored for RGBA input data.
5061+
This parameter is ignored for RGBA input data.
50555062
5056-
origin :['upper' |'lower'], optional, default: None
5063+
origin :{'upper','lower'}, optional
50575064
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`.
5065+
corner of the axes. The convention 'upper' is typically used for
5066+
matrices and images.
5067+
Defaults to :rc:`image.origin`.
5068+
5069+
Note that the vertical axes points upward for 'lower'
5070+
but downward for 'upper'.
5071+
5072+
extent : scalars (left, right, bottom, top), optional
5073+
The bounding box in data coordinates that the image will fill.
50595074
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.
5075+
By default, pixels have a size of (1, 1). They are centered on
5076+
integer coordinates and their center coordinates range from 0 to
5077+
columns-1 horizontally and from 0 to rows-1 vertically.
5078+
5079+
Note that the direction of the vertical axis and thus the default
5080+
values for top and bottom depend on *origin*:
5081+
5082+
- For ``origin == 'upper'`` the default is
5083+
``(-0.5, numcols-0.5, numrows-0.5, -0.5)``.
5084+
- For ``origin == 'lower'`` the default is
5085+
``(-0.5, numcols-0.5, -0.5, numrows-0.5)``.
5086+
5087+
See the example :doc:`/tutorials/intermediate/imshow_extent` for a
5088+
more detailed description.
50645089
50655090
shape : scalars (columns, rows), optional, default: None
5066-
For raw buffer images
5091+
For raw buffer images.
50675092
50685093
filternorm : bool, optional, default: True
50695094
A parameter for the antigrain image resize filter (see the
@@ -5074,17 +5099,26 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
50745099
that any sum of pixel weights must be equal to 1.0. So, the
50755100
filter function must produce a graph of the proper shape.
50765101
5077-
filterrad :scalar, optional, default: 4.0
5102+
filterrad :float > 0, optional, default: 4.0
50785103
The filter radius for filters that have a radius parameter, i.e.
5079-
when interpolation is one of: 'sinc', 'lanczos' or 'blackman'
5104+
when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
5105+
5106+
resample : bool, optional
5107+
When *True*, use a full resampling method. When *False*, only
5108+
resample when the output image is larger than the input image.
5109+
5110+
url : str, optional
5111+
Set the url of the created `.AxesImage`. See `.Artist.set_url`.
50805112
50815113
Returns
50825114
-------
50835115
image : `~matplotlib.image.AxesImage`
50845116
50855117
Other Parameters
50865118
----------------
5087-
**kwargs : `~matplotlib.artist.Artist` properties.
5119+
**kwargs : `~matplotlib.artist.Artist` properties
5120+
These parameters are passed on to the constructor of the
5121+
`.AxesImage` artist.
50885122
50895123
See also
50905124
--------
@@ -5096,7 +5130,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
50965130
coordinates. In other words: the origin will coincide with the center
50975131
of pixel (0, 0).
50985132
5099-
Two typical representations are used for RGB images with an alpha
5133+
There are two common representations for RGB images with an alpha
51005134
channel:
51015135
51025136
- Straight (unassociated) alpha: R, G, and B channels represent the
@@ -5122,8 +5156,6 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
51225156
ifim.get_clip_path()isNone:
51235157
# image does not already have clipping set, clip to axes patch
51245158
im.set_clip_path(self.patch)
5125-
#if norm is None and shape is None:
5126-
# im.set_clim(vmin, vmax)
51275159
ifvminisnotNoneorvmaxisnotNone:
51285160
im.set_clim(vmin,vmax)
51295161
else:
@@ -7273,7 +7305,7 @@ def matshow(self, Z, **kwargs):
72737305
72747306
Parameters
72757307
----------
7276-
Z : array-like(N, M)
7308+
Z : array-like(M, N)
72777309
The matrix to be displayed.
72787310
72797311
Returns

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp