# matplotlib.pyplot.savefig¶

matplotlib.pyplot.savefig(*args, **kwargs)[source]

Save the current figure.

Call signature:

savefig(fname, dpi=None, facecolor='w', edgecolor='w',
orientation='portrait', papertype=None, format=None,

Parameters: fnamestr or path-like or file-likeA path, or a Python file-like object, or possibly some backend-dependent object such as matplotlib.backends.backend_pdf.PdfPages. If format is set, it determines the output format, and the file is saved as fname. Note that fname is used verbatim, and there is no attempt to make the extension, if any, of fname match format, and no extension is appended. If format is not set, then the format is inferred from the extension of fname, if there is one. If format is not set and fname has no extension, then the file is saved with rcParams["savefig.format"] (default: 'png') and the appropriate extension is appended to fname. dpifloat or 'figure', default: rcParams["savefig.dpi"] (default: 'figure')The resolution in dots per inch. If 'figure', use the figure's dpi value. qualityint, default: rcParams["savefig.jpeg_quality"] (default: 95)Applicable only if format is 'jpg' or 'jpeg', ignored otherwise. The image quality, on a scale from 1 (worst) to 95 (best). Values above 95 should be avoided; 100 disables portions of the JPEG compression algorithm, and results in large files with hardly any gain in image quality. This parameter is deprecated. optimizebool, default: FalseApplicable only if format is 'jpg' or 'jpeg', ignored otherwise. Whether the encoder should make an extra pass over the image in order to select optimal encoder settings. This parameter is deprecated. progressivebool, default: FalseApplicable only if format is 'jpg' or 'jpeg', ignored otherwise. Whether the image should be stored as a progressive JPEG file. This parameter is deprecated. facecolorcolor or 'auto', default: rcParams["savefig.facecolor"] (default: 'auto')The facecolor of the figure. If 'auto', use the current figure facecolor. edgecolorcolor or 'auto', default: rcParams["savefig.edgecolor"] (default: 'auto')The edgecolor of the figure. If 'auto', use the current figure edgecolor. orientation{'landscape', 'portrait'}Currently only supported by the postscript backend. papertypestrOne of 'letter', 'legal', 'executive', 'ledger', 'a0' through 'a10', 'b0' through 'b10'. Only supported for postscript output. formatstrThe file format, e.g. 'png', 'pdf', 'svg', ... The behavior when this is unset is documented under fname. transparentboolIf True, the axes patches will all be transparent; the figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs. This is useful, for example, for displaying a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function. bbox_inchesstr or Bbox, default: rcParams["savefig.bbox"] (default: None)Bounding box in inches: only the given portion of the figure is saved. If 'tight', try to figure out the tight bbox of the figure. pad_inchesfloat, default: rcParams["savefig.pad_inches"] (default: 0.1)Amount of padding around the figure when bbox_inches is 'tight'. bbox_extra_artistslist of Artist, optionalA list of extra artists that will be considered when the tight bbox is calculated. backendstr, optionalUse a non-default backend to render the file, e.g. to render a png file with the "cairo" backend rather than the default "agg", or a pdf file with the "pgf" backend rather than the default "pdf". Note that the default backend is normally sufficient. See The builtin backends for a list of valid backends for each file format. Custom backends can be referenced as "module://...". metadatadict, optionalKey/value pairs to store in the image metadata. The supported keys and defaults depend on the image format and backend: 'png' with Agg backend: See the parameter metadata of print_png. 'pdf' with pdf backend: See the parameter metadata of PdfPages. 'svg' with svg backend: See the parameter metadata of print_svg. 'eps' and 'ps' with PS backend: Only 'Creator' is supported. pil_kwargsdict, optionalAdditional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.