# 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 PathLike or file-like objectA path, or a Python file-like object, or possibly some backend-dependent object such as matplotlib.backends.backend_pdf.PdfPages. If format is not set, then the output format is inferred from the extension of fname, if any, and from rcParams["savefig.format"] (default: 'png') otherwise. If format is set, it determines the output format. Hence, if fname is not a path or has no extension, remember to specify format to ensure that the correct backend is used. 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. 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. progressivebool, default: FalseApplicable only if format is 'jpg' or 'jpeg', ignored otherwise. Whether the image should be stored as a progressive JPEG file. facecolorcolor or None, optionalThe facecolor of the figure; if None, defaults to rcParams["savefig.facecolor"] (default: 'white'). edgecolorcolor or None, optionalThe edgecolor of the figure; if None, defaults to rcParams["savefig.edgecolor"] (default: 'white') 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, optionalBbox in inches. Only the given portion of the figure is saved. If 'tight', try to figure out the tight bbox of the figure. If None, use savefig.bbox pad_inchesscalar, optionalAmount of padding around the figure when bbox_inches is 'tight'. If None, use savefig.pad_inches bbox_extra_artistslist of Artist, optionalA list of extra artists that will be considered when the tight bbox is calculated. 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. 'eps' and 'ps' with PS backend: Only 'Creator' is supported. pil_kwargsdict, optionalAdditional keyword arguments that are passed to PIL.Image.save when saving the figure. Only applicable for formats that are saved using Pillow, i.e. JPEG, TIFF, and (if the keyword is set to a non-None value) PNG.