Display data as an image, i.e., on a 2D regular raster. The input may either be actual RGB(A) data, or 2D scalar data, which will be rendered as a pseudocolor image. For displaying a grayscale image, set up the colormapping using the parameters ``cmap='gray'
(self, X, cmap=None, norm=None, *, aspect=None,
interpolation=None, alpha=None,
vmin=None, vmax=None, colorizer=None, origin=None, extent=None,
interpolation_stage=None, filternorm=True, filterrad=4.0,
resample=None, url=None, **kwargs)
| 6145 | @_preprocess_data() |
| 6146 | @_docstring.interpd |
| 6147 | def imshow(self, X, cmap=None, norm=None, *, aspect=None, |
| 6148 | interpolation=None, alpha=None, |
| 6149 | vmin=None, vmax=None, colorizer=None, origin=None, extent=None, |
| 6150 | interpolation_stage=None, filternorm=True, filterrad=4.0, |
| 6151 | resample=None, url=None, **kwargs): |
| 6152 | """ |
| 6153 | Display data as an image, i.e., on a 2D regular raster. |
| 6154 | |
| 6155 | The input may either be actual RGB(A) data, or 2D scalar data, which |
| 6156 | will be rendered as a pseudocolor image. For displaying a grayscale |
| 6157 | image, set up the colormapping using the parameters |
| 6158 | ``cmap='gray', vmin=0, vmax=255``. |
| 6159 | |
| 6160 | The number of pixels used to render an image is set by the Axes size |
| 6161 | and the figure *dpi*. This can lead to aliasing artifacts when |
| 6162 | the image is resampled, because the displayed image size will usually |
| 6163 | not match the size of *X* (see |
| 6164 | :doc:`/gallery/images_contours_and_fields/image_antialiasing`). |
| 6165 | The resampling can be controlled via the *interpolation* parameter |
| 6166 | and/or :rc:`image.interpolation`. |
| 6167 | |
| 6168 | Parameters |
| 6169 | ---------- |
| 6170 | X : array-like or PIL image |
| 6171 | The image data. Supported array shapes are: |
| 6172 | |
| 6173 | - (M, N): an image with scalar data. The values are mapped to |
| 6174 | colors using normalization and a colormap. See parameters *norm*, |
| 6175 | *cmap*, *vmin*, *vmax*. |
| 6176 | - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). |
| 6177 | - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), |
| 6178 | i.e. including transparency. |
| 6179 | |
| 6180 | The first two dimensions (M, N) define the rows and columns of |
| 6181 | the image. |
| 6182 | |
| 6183 | Out-of-range RGB(A) values are clipped. |
| 6184 | |
| 6185 | %(cmap_doc)s |
| 6186 | |
| 6187 | This parameter is ignored if *X* is RGB(A). |
| 6188 | |
| 6189 | %(norm_doc)s |
| 6190 | |
| 6191 | This parameter is ignored if *X* is RGB(A). |
| 6192 | |
| 6193 | %(vmin_vmax_doc)s |
| 6194 | |
| 6195 | This parameter is ignored if *X* is RGB(A). |
| 6196 | |
| 6197 | %(colorizer_doc)s |
| 6198 | |
| 6199 | This parameter is ignored if *X* is RGB(A). |
| 6200 | |
| 6201 | aspect : {'equal', 'auto'} or float or None, default: None |
| 6202 | The aspect ratio of the Axes. This parameter is particularly |
| 6203 | relevant for images since it determines whether data pixels are |
| 6204 | square. |