Figure.savefig(fname, transparent=False, crop=True, anti_alias=True, show=False, worldfile=False, **kwargs)[source]

Save the figure to an image file.

Supported image formats and their extensions:

Raster image formats

  • BMP (.bmp)

  • JPEG (.jpg or .jpeg)

  • GeoTIFF (.tiff)

  • PNG (.png)

  • PPM (.ppm)

  • TIFF (.tif)

Vector image formats

  • EPS (.eps)

  • PDF (.pdf)

Beside the above formats, you can also save the figure to a KML file (.kml), with a companion PNG file generated automatically. The KML file can be viewed in Google Earth.

You can pass in any keyword arguments that pygmt.Figure.psconvert accepts.

  • fname (str) – The desired figure file name, including the extension. See the list of supported formats and their extensions above.

  • transparent (bool) – If True, will use a transparent background for the figure. Only valid for PNG format.

  • crop (bool) – If True, will crop the figure canvas (page) to the plot area.

  • anti_alias (bool) – If True, will use anti-aliasing when creating raster images. More specifically, it passes the arguments "t2" and "g2" to the anti_aliasing parameter of pygmt.Figure.psconvert. Ignored if creating vector images.

  • show (bool) – If True, will open the figure in an external viewer.

  • worldfile (bool) – If True, will create a companion world file for the figure. The world file will have the same name as the figure file but with different extension (e.g. tfw for tif). See for the convention of world file extensions. This parameter only works for raster image formats (except GeoTIFF).

  • dpi (int) – Set raster resolution in dpi [Default is 720 for PDF, 300 for others].

  • **kwargs (dict) – Additional keyword arguments passed to pygmt.Figure.psconvert. Valid parameters are gs_path, gs_option, resize, bb_style, and verbose.