The image module supports basic image loading, rescaling and display operations.
class matplotlib.image.AxesImage(ax, cmap=None, norm=None, interpolation=None, origin=None, extent=None, filternorm=1, filterrad=4.0, resample=False, **kwargs)
[source]
Bases: matplotlib.image._ImageBase
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_cursor_data(event)
[source]
Get the cursor data for a given event
get_extent()
[source]
Get the image extent: left, right, bottom, top
get_window_extent(renderer=None)
[source]
Get the axes bounding box in display space. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
make_image(renderer, magnification=1.0, unsampled=False)
[source]
set_extent(extent)
[source]
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.
class matplotlib.image.BboxImage(bbox, cmap=None, norm=None, interpolation=None, origin=None, filternorm=1, filterrad=4.0, resample=False, interp_at_native=True, **kwargs)
[source]
Bases: matplotlib.image._ImageBase
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
contains(mouseevent)
[source]
Test whether the mouse event occurred within the image.
get_window_extent(renderer=None)
[source]
Get the axes bounding box in display space. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
make_image(renderer, magnification=1.0, unsampled=False)
[source]
class matplotlib.image.FigureImage(fig, cmap=None, norm=None, offsetx=0, offsety=0, origin=None, **kwargs)
[source]
Bases: matplotlib.image._ImageBase
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
get_extent()
[source]
Get the image extent: left, right, bottom, top
make_image(renderer, magnification=1.0, unsampled=False)
[source]
set_data(A)
[source]
Set the image array.
zorder = 0
class matplotlib.image.NonUniformImage(ax, *, interpolation='nearest', **kwargs)
[source]
Bases: matplotlib.image.AxesImage
kwargs are identical to those for AxesImage, except that 'nearest' and 'bilinear' are the only supported 'interpolation' options.
get_extent()
[source]
Get the image extent: left, right, bottom, top
make_image(renderer, magnification=1.0, unsampled=False)
[source]
set_array(*args)
[source]
Retained for backwards compatibility - use set_data instead.
Parameters: |
|
---|
set_cmap(cmap)
[source]
set the colormap for luminance data
Parameters: |
|
---|
set_data(x, y, A)
[source]
Set the grid for the pixel centers, and the pixel values.
set_filternorm(s)
[source]
Set whether the resize filter normalizes the weights.
See help for imshow
.
Parameters: |
|
---|
set_filterrad(s)
[source]
Set the resize filter radius only applicable to some interpolation schemes -- see help for imshow
Parameters: |
|
---|
set_interpolation(s)
[source]
Parameters: |
|
---|
set_norm(norm)
[source]
Set the normalization instance.
Parameters: |
|
---|
class matplotlib.image.PcolorImage(ax, x=None, y=None, A=None, cmap=None, norm=None, **kwargs)
[source]
Bases: matplotlib.image.AxesImage
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
get_cursor_data(event)
[source]
Get the cursor data for a given event
make_image(renderer, magnification=1.0, unsampled=False)
[source]
set_array(*args)
[source]
Retained for backwards compatibility - use set_data instead.
Parameters: |
|
---|
set_data(x, y, A)
[source]
Set the grid for the rectangle boundaries, and the data values.
matplotlib.image.composite_images(images, renderer, magnification=1.0)
[source]
Composite a number of RGBA images into one. The images are composited in the order in which they appear in the images
list.
Parameters: |
|
---|---|
Returns: |
|
matplotlib.image.imread(fname, format=None)
[source]
Read an image from a file into an array.
Parameters: |
|
---|---|
Returns: |
|
Matplotlib can only read PNGs natively. Further image formats are supported via the optional dependency on Pillow. Note, URL strings are not compatible with Pillow. Check the Pillow documentation for more information.
matplotlib.image.imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, origin=None, dpi=100)
[source]
Save an array as in image file.
The output formats available depend on the backend being used.
Parameters: |
|
---|
matplotlib.image.pil_to_array(pilImage)
[source]
Load a PIL image and return it as a numpy array.
Returns: |
|
---|
matplotlib.image.thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear', preview=False)
[source]
Make a thumbnail of image in infile with output filename thumbfile.
See Image Thumbnail.
Parameters: |
|
---|---|
Returns: |
|
© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.0.0/api/image_api.html