matplotlib.pyplot.figimage#

matplotlib.pyplot.figimage(X,xo=0,yo=0,alpha=None,norm=None,cmap=None,vmin=None,vmax=None,origin=None,resize=False,*,colorizer=None,**kwargs)[source]#

Add a non-resampled image to the figure.

The image is attached to the lower or upper left corner depending onorigin.

Parameters:
X

The image data. This is an array of one of the following shapes:

  • (M, N): an image with scalar data. Color-mapping is controlledbycmap,norm,vmin, andvmax.

  • (M, N, 3): an image with RGB values (0-1 float or 0-255 int).

  • (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),i.e. including transparency.

xo, yoint

Thex/y image offset in pixels.

alphaNone or float

The alpha blending value.

cmapstr orColormap, default:rcParams["image.cmap"] (default:'viridis')

The Colormap instance or registered colormap name used to map scalar datato colors.

This parameter is ignored ifX is RGB(A).

normstr orNormalize, optional

The normalization method used to scale scalar data to the [0, 1] rangebefore mapping to colors usingcmap. By default, a linear scaling isused, mapping the lowest value to 0 and the highest to 1.

If given, this can be one of the following:

This parameter is ignored ifX is RGB(A).

vmin, vmaxfloat, optional

When using scalar data and no explicitnorm,vmin andvmax definethe data range that the colormap covers. By default, the colormap coversthe complete value range of the supplied data. It is an error to usevmin/vmax when anorm instance is given (but using astrnormname together withvmin/vmax is acceptable).

This parameter is ignored ifX is RGB(A).

origin{'upper', 'lower'}, default:rcParams["image.origin"] (default:'upper')

Indicates where the [0, 0] index of the array is in the upper leftor lower left corner of the Axes.

resizebool

IfTrue, resize the figure to match the given image size.

colorizerColorizer or None, default: None

The Colorizer object used to map color to data. If None, a Colorizerobject is created from anorm andcmap.

This parameter is ignored ifX is RGB(A).

Returns:
matplotlib.image.FigureImage
Other Parameters:
**kwargs

Additional kwargs areArtist kwargs passed on toFigureImage.

Notes

Note

This is thepyplot wrapper forFigure.figimage.

figimage complements the Axes image (imshow)which will be resampled to fit the current Axes. If you wanta resampled image to fill the entire figure, you can define anAxes with extent [0, 0, 1, 1].

Examples

f=plt.figure()nx=int(f.get_figwidth()*f.dpi)ny=int(f.get_figheight()*f.dpi)data=np.random.random((ny,nx))f.figimage(data)plt.show()

Examples usingmatplotlib.pyplot.figimage#

Figimage Demo

Figimage Demo