pygmt.Figure¶
-
class
pygmt.
Figure
[source]¶ A GMT figure to handle all plotting.
Use the plotting methods of this class to add elements to the figure. You can preview the figure using
pygmt.Figure.show
and save the figure to a file usingpygmt.Figure.savefig
.Unlike traditional GMT figures, no figure file is generated until you call
pygmt.Figure.savefig
orpygmt.Figure.psconvert
.Examples
>>> fig = Figure() >>> fig.basemap(region=[0, 360, -90, 90], projection='W7i', frame=True) >>> fig.savefig("my-figure.png") >>> # Make sure the figure file is generated and clean it up >>> import os >>> os.path.exists('my-figure.png') True >>> os.remove('my-figure.png')
The plot region can be specified through ISO country codes (for example,
'JP'
for Japan):>>> fig = Figure() >>> fig.basemap(region='JP', projection="M3i", frame=True) >>> # The fig.region attribute shows the WESN bounding box for the figure >>> print(', '.join('{:.2f}'.format(i) for i in fig.region)) 122.94, 145.82, 20.53, 45.52
Attributes: region
The geographic WESN bounding box for the current figure.
Methods
basemap
(self, \*\*kwargs)Produce a basemap for the figure. coast
(self, \*\*kwargs)Plot continents, shorelines, rivers, and borders on maps contour
(self[, x, y, z, data])Contour table data by direct triangulation. grdcontour
(self, grid, \*\*kwargs)Convert grids or images to contours and plot them on maps grdimage
(self, grid, \*\*kwargs)Project grids or images and plot them on maps. image
(self, imagefile, \*\*kwargs)Place images or EPS files on maps. logo
(self, \*\*kwargs)Place the GMT graphics logo on a map. plot
(self[, x, y, data, sizes, direction])Plot lines, polygons, and symbols on maps. psconvert
(self, \*\*kwargs)Convert [E]PS file(s) to other formats. savefig
(self, fname[, transparent, crop, …])Save the figure to a file. shift_origin
(self[, xshift, yshift])Shift plot origin in x and/or y directions. show
(self[, dpi, width, method])Display a preview of the figure.