The image module supports basic image loading, rescaling and display operations.
Bases: matplotlib.image._AxesImageBase
interpolation and cmap default to their rc settings
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
extent is data axes (left, right, bottom, top) for making image plots registered with data plots. Default is to label the pixel centers with the zero-based row and column indices.
Additional kwargs are matplotlib.artist properties
Get the image extent: left, right, bottom, top
extent is data axes (left, right, bottom, top) for making image plots
This updates ax.dataLim, and, if autoscaling, sets viewLim to tightly fit the image, regardless of dataLim. Autoscaling state is not changed, so following this with ax.autoscale_view will redo the autoscaling in accord with dataLim.
Bases: matplotlib.image._AxesImageBase
The Image class whose size is determined by the given bbox.
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
interp_at_native is a flag that determines whether or not interpolation should still be applied when the image is displayed at its native resolution. A common use case for this is when displaying an image for annotational purposes; it is treated similarly to Photoshop (interpolation is only used when displaying the image at non-native resolutions).
kwargs are an optional list of Artist keyword args
Test whether the mouse event occured within the image.
Get the numrows, numcols of the input image
Bases: matplotlib.artist.Artist, matplotlib.cm.ScalarMappable
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
kwargs are an optional list of Artist keyword args
Test whether the mouse event occured within the image.
Get the image extent: left, right, bottom, top
Get the numrows, numcols of the input image
Deprecated; use set_data for consistency with other image types.
Set the image array.
Write the image to png file with fname
Bases: matplotlib.image.AxesImage
kwargs are identical to those for AxesImage, except that ‘interpolation’ defaults to ‘nearest’, and ‘bilinear’ is the only alternative.
Set the grid for the pixel centers, and the pixel values.
- x and y are 1-D ndarrays of lengths N and M, respectively,
- specifying pixel centers
- A is an (M,N) ndarray or masked array of values to be
- colormapped, or a (M,N,3) RGB array, or a (M,N,4) RGBA array.
Bases: matplotlib.artist.Artist, matplotlib.cm.ScalarMappable
Make a pcolor-style plot with an irregular rectangular grid.
This uses a variation of the original irregular image code, and it is used by pcolorfast for the corresponding grid type.
cmap defaults to its rc setting
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
Additional kwargs are matplotlib.artist properties
Set the alpha value used for blending - not supported on all backends
ACCEPTS: float
Read an image from a file into an array.
fname may be a string path or a Python file-like object. If using a file object, it must be opened in binary mode.
If format is provided, will try to read file of that type, otherwise the format is deduced from the filename. If nothing can be deduced, PNG is tried.
Return value is a numpy.array. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4.
matplotlib can only read PNGs natively, but if PIL is installed, it will use it to load the image and return an array (if possible) which can be used with imshow().
Save an array as in image file.
The output formats available depend on the backend being used.
Load a PIL image and return it as a numpy array. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4
make a thumbnail of image in infile with output filename thumbfile.
- infile the image file – must be PNG or PIL readable if you
- have PIL installed
- thumbfile
- the thumbnail filename
- scale
- the scale factor for the thumbnail
- interpolation
- the interpolation scheme used in the resampling
- preview
- if True, the default backend (presumably a user interface backend) will be used which will cause a figure to be raised if show() is called. If it is False, a pure image backend will be used depending on the extension, ‘png’->FigureCanvasAgg, ‘pdf’->FigureCanvasPdf, ‘svg’->FigureCanvasSVG
See examples/misc/image_thumbnail.py.
misc example code: image_thumbnail.pyReturn value is the figure instance containing the thumbnail