You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Version 2.0.0b1.post7580.dev0+ge487118
matplotlib
Fork me on GitHub

This Page

matplotlib.pyplot.imsave

matplotlib.pyplot.imsave(*args, **kwargs)

Save an array as in image file.

The output formats available depend on the backend being used.

Parameters:

fname : str or file-like

Path string to a filename, or a Python file-like object. If format is None and fname is a string, the output format is deduced from the extension of the filename.

arr : array-like

An MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA) array.

vmin, vmax: [ None | scalar ]

vmin and vmax set the color scaling for the image by fixing the values that map to the colormap color limits. If either vmin or vmax is None, that limit is determined from the arr min/max value.

cmap : matplotlib.colors.Colormap, optional

For example, cm.viridis. If None, defaults to the image.cmap rcParam.

format : str

One of the file extensions supported by the active backend. Most backends support png, pdf, ps, eps and svg.

origin : [ ‘upper’ | ‘lower’ ]

Indicates whether the (0, 0) index of the array is in the upper left or lower left corner of the axes. Defaults to the image.origin rcParam.

dpi : int

The DPI to store in the metadata of the file. This does not affect the resolution of the output image.