pygmt.Figure.savefig
- 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 (
.jpgor.jpeg)GeoTIFF (
.tiff)PNG (
.png)PPM (
.ppm)TIFF (
.tif)
Vector image formats
EPS (
.eps)PDF (
.pdf)
Besides 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.psconvertaccepts.- Parameters:
fname (
str|PathLike) – The desired figure file name, including the extension. See the list of supported formats and their extensions above.transparent (
bool, default:False) – Use a transparent background for the figure. Only valid for PNG format and the PNG file asscoiated with KML format.crop (
bool, default:True) – Crop the figure canvas (page) to the plot area.anti_alias (
bool, default:True) – Use anti-aliasing when creating raster images. Ignored if creating vector images. More specifically, it passes the arguments"t2"and"g2"to theanti_aliasingparameter ofpygmt.Figure.psconvert.show (
bool, default:False) – Display the figure in an external viewer.worldfile (
bool, default:False) – 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.,.tfwfor.tif). See https://en.wikipedia.org/wiki/World_file#Filename_extension for the convention of world file extensions. This parameter only works for raster image formats (except GeoTIFF).**kwargs (dict) – Additional keyword arguments passed to
pygmt.Figure.psconvert. Valid parameters aredpi,gs_path,gs_option,resize,bb_style, andverbose.
- Return type: