Maps.savefig(**kwargs) None

Save the current figure as an image or vector graphic to a file.

Call signature:

savefig(fname, *, transparent=None, dpi='figure', format=None,
        metadata=None, bbox_inches=None, pad_inches=0.1,
        facecolor='auto', edgecolor='auto', backend=None,

The available output formats depend on the backend being used.

  • fname (str or path-like or binary file-like) –

    A 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 matpltolib rcParams[‘savefig.format’] and the appropriate extension is appended to fname.

  • refetch_wms (bool) –

    If True, re-fetch EOmaps WebMap services with respect to the dpi of the exported figure before exporting the image.

    NOTE: This might fail for high-dpi exports and might result in a completely different appearance of the wms-images in the exported file!

    See m.refetch_wms_on_size_change() for more details. The default is False

  • transparent (bool, default: matpltolib rcParams[‘savefig.transparent’]) –

    If True, the Axes patches will all be transparent; the Figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs.

    If False has no effect and the color of the Axes and Figure patches are unchanged (unless the Figure patch is specified via the facecolor and/or edgecolor keyword arguments in which case those colors are used).

    The transparency of these patches will be restored to their original values upon exit of this function.

    This is useful, for example, for displaying a plot on top of a colored background on a web page.

  • dpi (float or ‘figure’, default: matpltolib rcParams[‘savefig.dpi’]) – The resolution in dots per inch. If ‘figure’, use the figure’s dpi value.

  • format (str) – The file format, e.g. ‘png’, ‘pdf’, ‘svg’, … The behavior when this is unset is documented under fname.

  • metadata (dict, optional) –

    Key/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 ~.FigureCanvasAgg.print_png.

    • ’pdf’ with pdf backend: See the parameter metadata of ~.backend_pdf.PdfPages.

    • ’svg’ with svg backend: See the parameter metadata of ~.FigureCanvasSVG.print_svg.

    • ’eps’ and ‘ps’ with PS backend: Only ‘Creator’ is supported.

    Not supported for ‘pgf’, ‘raw’, and ‘rgba’ as those formats do not support embedding metadata. Does not currently support ‘jpg’, ‘tiff’, or ‘webp’, but may include embedding EXIF metadata in the future.

  • bbox_inches (str or .Bbox, default: matpltolib rcParams[‘savefig.bbox’]) – 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_inches (float or ‘layout’, default: matpltolib rcParams[‘savefig.pad_inches’]) – Amount of padding in inches around the figure when bbox_inches is ‘tight’. If ‘layout’ use the padding from the constrained or compressed layout engine; ignored if one of those engines is not in use.

  • facecolor (:mpltype:`color` or ‘auto’, default: matpltolib rcParams[‘savefig.facecolor’]) – The facecolor of the figure. If ‘auto’, use the current figure facecolor.

  • edgecolor (:mpltype:`color` or ‘auto’, default: matpltolib rcParams[‘savefig.edgecolor’]) – The edgecolor of the figure. If ‘auto’, use the current figure edgecolor.

  • backend (str, optional) – Use 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://…”.

  • orientation ({'landscape', 'portrait'}) – Currently only supported by the postscript backend.

  • papertype (str) – One of ‘letter’, ‘legal’, ‘executive’, ‘ledger’, ‘a0’ through ‘a10’, ‘b0’ through ‘b10’. Only supported for postscript output.

  • bbox_extra_artists (list of ~matplotlib.artist.Artist, optional) – A list of extra artists that will be considered when the tight bbox is calculated.

  • pil_kwargs (dict, optional) – Additional keyword arguments that are passed to when saving the figure.



This is the pyplot wrapper for .Figure.savefig.