@@ -255,20 +255,27 @@ def savefig(
255
255
self , fname , transparent = False , crop = True , anti_alias = True , show = False , ** kwargs
256
256
):
257
257
"""
258
- Save the figure to a file.
258
+ Save the figure to an image file.
259
259
260
- Supported file formats and their extensions:
260
+ Supported image formats and their extensions:
261
+
262
+ **Raster image formats**
261
263
262
- - PNG (``.png``)
263
- - JPEG (``.jpg`` or ``.jpeg``)
264
- - PDF (``.pdf``)
265
264
- BMP (``.bmp``)
266
- - TIFF (``.tif ``)
265
+ - JPEG (``.jpg`` or ``.jpeg ``)
267
266
- GeoTIFF (``.tiff``)
267
+ - PNG (``.png``)
268
+ - PPM (``.ppm``)
269
+ - TIFF (``.tif``)
270
+
271
+ **Vector image formats**
272
+
268
273
- EPS (``.eps``)
269
- - KML (``.kml ``)
274
+ - PDF (``.pdf ``)
270
275
271
- For KML format, a companion PNG file is also generated.
276
+ Beside the above formats, you can also save the figure to a KML file
277
+ (``.kml``), with a companion PNG file generated automatically. The KML
278
+ file can be viewed in Google Earth.
272
279
273
280
You can pass in any keyword arguments that
274
281
:meth:`pygmt.Figure.psconvert` accepts.
@@ -284,11 +291,10 @@ def savefig(
284
291
crop : bool
285
292
If ``True``, will crop the figure canvas (page) to the plot area.
286
293
anti_alias: bool
287
- If ``True``, will use anti-aliasing when creating raster images
288
- (BMP, PNG, JPEG, TIFF, and GeoTIFF). More specifically, it passes
289
- the arguments ``"t2"`` and ``"g2"`` to the ``anti_aliasing``
290
- parameter of :meth:`pygmt.Figure.psconvert`. Ignored if creating
291
- vector graphics.
294
+ If ``True``, will use anti-aliasing when creating raster images.
295
+ More specifically, it passes the arguments ``"t2"`` and ``"g2"``
296
+ to the ``anti_aliasing`` parameter of
297
+ :meth:`pygmt.Figure.psconvert`. Ignored if creating vector images.
292
298
show: bool
293
299
If ``True``, will open the figure in an external viewer.
294
300
dpi : int
@@ -301,14 +307,15 @@ def savefig(
301
307
"""
302
308
# All supported formats
303
309
fmts = {
304
- "png" : "g" ,
305
- "pdf" : "f" ,
306
- "jpg" : "j" ,
307
310
"bmp" : "b" ,
308
311
"eps" : "e" ,
312
+ "jpg" : "j" ,
313
+ "kml" : "g" ,
314
+ "pdf" : "f" ,
315
+ "png" : "g" ,
316
+ "ppm" : "m" ,
309
317
"tif" : "t" ,
310
318
"tiff" : None , # GeoTIFF doesn't need the -T option
311
- "kml" : "g" ,
312
319
}
313
320
314
321
fname = Path (fname )
0 commit comments