GeezerVison is showing www.pygmt.org — API Reference — PyGMT
API Reference
This page gives an overview of all public PyGMT objects, functions and methods.
Plotting
Figure class overview
All plotting is handled through the pygmt.Figure class and its methods.
Figure()
|
A GMT figure to handle all plotting. |
Plotting figure elements
Figure.basemap([projection, zscale, zsize, ...])
|
Plot base maps and frames. |
Figure.choropleth(data, column[, cmap, ...])
|
Plot a choropleth map. |
Figure.coast([resolution, land, water, ...])
|
Plot continents, countries, shorelines, rivers, and borders. |
Figure.colorbar([cmap, position, length, ...])
|
Plot gray scale or color scale bar. |
Figure.directional_rose([position, width, ...])
|
Add a directional rose on the map. |
Figure.hlines(y[, xmin, xmax, pen, label, ...])
|
Plot one or multiple horizontal line(s). |
Figure.inset([position, width, height, box, ...])
|
Manage figure inset setup and completion. |
Figure.legend([spec, position, width, ...])
|
Plot a legend. |
Figure.logo([position, width, height, box, ...])
|
Plot the GMT logo. |
Figure.magnetic_rose([position, width, ...])
|
Add a magnetic rose to the map. |
Figure.paragraph(x, y, text, parwidth, ...)
|
Typeset one or multiple paragraphs. |
Figure.pygmtlogo([shape, theme, wordmark, ...])
|
Plot the PyGMT logo. |
Figure.scalebar(length[, height, position, ...])
|
Add a scale bar on the plot. |
Figure.solar([terminator, ...])
|
Plot day-night terminators and other sunlight parameters. |
Figure.text([textfiles, x, y, position, ...])
|
Plot or typeset text. |
Figure.timestamp([text, label, justify, ...])
|
Plot the GMT timestamp logo. |
Figure.vlines(x[, ymin, ymax, pen, label, ...])
|
Plot one or multiple vertical line(s). |
Plotting tabular data
Figure.contour([data, x, y, z, no_clip, ...])
|
Contour table data by direct triangulation. |
Figure.fill_between(x, y[, y2, x2, fill, ...])
|
Fill the area between two horizontal curves. |
Figure.histogram(data[, weights, histtype, ...])
|
Calculate and plot histograms. |
Figure.meca(spec, scale[, convention, ...])
|
Plot focal mechanisms. |
Figure.plot([data, x, y, size, symbol, ...])
|
Plot lines, polygons, and symbols in 2-D. |
Figure.plot3d([data, x, y, z, size, symbol, ...])
|
Plot lines, polygons, and symbols in 3-D. |
Figure.rose([data, length, azimuth, cmap, ...])
|
Plot a polar histogram (rose, sector, windrose diagrams). |
Figure.ternary(data[, cmap, fill, width, ...])
|
Plot data on ternary diagrams. |
Figure.velo([data, cmap, no_clip, ...])
|
Plot velocity vectors, strain crosses, anisotropy bars, and wedges. |
Figure.wiggle([data, x, y, z, position, ...])
|
Plot z=f(x,y) anomalies along tracks. |
Plotting raster data
Figure.grdcontour(grid[, projection, ...])
|
Make contour map using a grid. |
Figure.grdimage(grid[, cmap, monochrome, ...])
|
Project and plot grids or images. |
Figure.grdview(grid[, cmap, drape_grid, ...])
|
Create 3-D perspective image or surface mesh from a grid. |
Figure.image(imagefile[, position, width, ...])
|
Plot raster or EPS images. |
Figure.tilemap(region[, zoom, source, ...])
|
Plot an XYZ tile map. |
Configuring layout
Figure.set_panel([panel, tag, verbose, ...])
|
Set the current subplot panel to plot on. |
Figure.shift_origin([xshift, yshift])
|
Shift the plot origin in x- and/or y-directions. |
Figure.subplot([nrows, ncols, tag, ...])
|
Manage figure subplot configuration and selection. |
Saving and displaying the figure
Figure.savefig(fname[, transparent, crop, ...])
|
Save the figure to an image file. |
Figure.show([method, dpi, width, waiting])
|
Display a preview of the figure. |
Figure.psconvert([prefix, dpi, gs_option, ...])
|
Convert [E]PS file(s) to other formats using Ghostscript. |
Configuring the display settings
The following function is provided directly through the pygmt top level
package.
Color palette table generation
The following functions are provided directly through the pygmt top level
package.
grd2cpt(grid[, cmap, truncate, overrule_bg, ...])
|
Make linear or histogram-equalized color palette table from grid. |
makecpt([cmap, truncate, overrule_bg, ...])
|
Make GMT color palette tables. |
Data Processing
Operations on tabular data
binstats(data[, outgrid, spacing, ...])
|
Bin spatial data and determine statistics per bin. |
blockmean([data, x, y, z, output_type, ...])
|
Block average (x, y, z) data tables by mean estimation. |
blockmedian([data, x, y, z, output_type, ...])
|
Block average (x, y, z) data tables by median estimation. |
blockmode([data, x, y, z, output_type, ...])
|
Block average (x, y, z) data tables by mode estimation. |
filter1d(data[, output_type, outfile, ...])
|
Time domain filtering of 1-D data tables. |
nearneighbor([data, x, y, z, outgrid, ...])
|
Grid table data using a "Nearest neighbor" algorithm. |
project([data, x, y, z, output_type, ...])
|
Project data onto lines or great circles, or generate tracks. |
select([data, output_type, outfile, ...])
|
Select data table subsets based on multiple spatial criteria. |
sph2grd(data[, outgrid, spacing, region, ...])
|
Compute grid from spherical harmonic coefficients. |
sphdistance([data, x, y, outgrid, spacing, ...])
|
Create Voronoi distance, node, or natural nearest-neighbor grid on a sphere. |
sphinterpolate(data[, outgrid, spacing, ...])
|
Spherical gridding in tension of data on a sphere. |
surface([data, x, y, z, outgrid, spacing, ...])
|
Grid table data using adjustable tension continuous curvature splines. |
triangulate()
|
Delaunay triangulation or Voronoi partitioning and gridding of Cartesian data. |
triangulate.regular_grid([data, x, y, z, ...])
|
Delaunay triangle based gridding of Cartesian data. |
triangulate.delaunay_triples([data, x, y, ...])
|
Delaunay triangle based gridding of Cartesian data. |
xyz2grd([data, x, y, z, outgrid, spacing, ...])
|
Convert data table to a grid. |
Operations on raster data
dimfilter(grid[, outgrid, spacing, region, ...])
|
Directional filtering of grids in the space domain. |
grd2xyz(grid[, output_type, outfile, ...])
|
Convert grid to data table. |
grdclip(grid[, outgrid, above, below, ...])
|
Clip the range of grid values. |
grdcut(grid[, kind, outgrid, projection, ...])
|
Extract subregion from a grid or image or a slice from a cube. |
grdfill(grid[, outgrid, constant_fill, ...])
|
Interpolate across holes in a grid. |
grdfilter(grid[, outgrid, filter, width, ...])
|
Filter a grid in the space (or time) domain. |
grdgradient(grid[, outgrid, azimuth, ...])
|
Compute directional gradients from a grid. |
grdhisteq()
|
Perform histogram equalization for a grid. |
grdhisteq.equalize_grid(grid[, outgrid, ...])
|
Perform histogram equalization for a grid. |
grdhisteq.compute_bins(grid[, output_type, ...])
|
Perform histogram equalization for a grid. |
grdlandmask([outgrid, spacing, mask_values, ...])
|
Create a "wet-dry" mask grid from shoreline database. |
grdmask(data[, outgrid, spacing, region, ...])
|
Create mask grid from polygons or point coverage. |
grdpaste(grid1, grid2[, outgrid, verbose, ...])
|
Join two grids along their common edge. |
grdproject(grid[, outgrid, center, spacing, ...])
|
Forward and inverse map transformation of grids. |
grdsample(grid[, outgrid, toggle, spacing, ...])
|
Resample a grid onto a new lattice. |
grdtrack(grid[, points, output_type, ...])
|
Sample one or more grids at specified locations. |
grdvolume(grid[, output_type, outfile, ...])
|
Calculate grid volume and area constrained by a contour. |
Crossover analysis with x2sys
x2sys_init(tag[, spacing, region, verbose, ...])
|
Initialize a new x2sys track database. |
x2sys_cross([tracks, outfile, region, ...])
|
Calculate crossovers between track data files. |
GMT Defaults
Operations on GMT defaults:
config(*[, COLOR_BACKGROUND, ...])
|
Change GMT default settings globally or locally. |
Metadata
Getting metadata from tabular or grid data:
info(data[, spacing, per_column, incols, ...])
|
Get information about data tables. |
grdinfo(grid[, spacing, tiles, region, ...])
|
Extract information from 2-D grids or 3-D cubes. |
Class-style Parameters
Axis([annot, tick, grid, end_skip, label, ...])
|
Class for setting up one axis of a plot. |
Box([clearance, fill, inner_gap, inner_pen, ...])
|
Class for specifying the box around GMT embellishments. |
Frame([axes, title, subtitle, fill, axis, ...])
|
Class for setting up the frame and axes of a plot. |
Pattern([pattern, dpi, bgcolor, fgcolor, invert])
|
Class for specifying bit and hachure patterns. |
Position(refpoint[, cstype, anchor, offset])
|
Class for positioning embellishments on a plot. |
Miscellaneous
which(fname[, download, verbose])
|
Find full path to specified files. |
show_versions([file])
|
Print various dependency versions which are useful when submitting bug reports. |
Datasets
PyGMT provides access to GMT’s datasets through the pygmt.datasets module.
These functions will download the datasets automatically the first time they are used
and store them in GMT’s user data directory.
datasets.list_sample_data()
|
Report datasets available for tests and documentation examples. |
datasets.load_black_marble([resolution, region])
|
Load NASA Black Marble images in various resolutions. |
datasets.load_blue_marble([resolution, region])
|
Load NASA Blue Marble images in various resolutions. |
datasets.load_earth_age([resolution, ...])
|
Load Earth's seafloor crustal age dataset in various resolutions. |
datasets.load_earth_deflection([resolution, ...])
|
Load the IGPP Earth's east-west and north-south deflection datasets in various resolutions. |
datasets.load_earth_dist([resolution, ...])
|
Load the GSHHG Earth's distance to shoreline dataset in various resolutions. |
datasets.load_earth_free_air_anomaly([...])
|
Load the IGPP Earth's free-air anomaly and uncertainty datasets in various resolutions. |
datasets.load_earth_geoid([resolution, ...])
|
Load the EGM2008 Earth's geoid dataset in various resolutions. |
datasets.load_earth_magnetic_anomaly([...])
|
Load Earth's magnetic anomaly datasets in various resolutions. |
datasets.load_earth_mask([resolution, ...])
|
Load the GSHHG Earth's mask dataset in various resolutions. |
datasets.load_earth_mean_dynamic_topography([...])
|
Load the CNES Earth's mean dynamic topography dataset in various resolutions. |
datasets.load_earth_mean_sea_surface([...])
|
Load the CNES Earth's mean sea surface dataset in various resolutions. |
datasets.load_earth_relief([resolution, ...])
|
Load Earth's relief datasets (topography and bathymetry) in various resolutions. |
datasets.load_earth_vertical_gravity_gradient([...])
|
Load the IGPP Earth's vertical gravity gradient dataset in various resolutions. |
datasets.load_mars_relief([resolution, ...])
|
Load Mars' relief dataset in various resolutions. |
datasets.load_mercury_relief([resolution, ...])
|
Load Mercury's relief dataset in various resolutions. |
datasets.load_moon_relief([resolution, ...])
|
Load Moon's relief dataset in various resolutions. |
datasets.load_pluto_relief([resolution, ...])
|
Load Pluto's relief dataset in various resolutions. |
datasets.load_venus_relief([resolution, ...])
|
Load Venus' relief dataset in various resolutions. |
datasets.load_sample_data(name)
|
Load an example dataset from the GMT server. |
In addition, there is also a special function to load XYZ tile maps via
contextily to be used as base maps.
GMT C API
The pygmt.clib package is a wrapper for the GMT C API built using ctypes.
Most calls to the C API happen through the pygmt.clib.Session class.
clib.Session()
|
A GMT API session where most operations involving the C API happen. |
GMT modules are executed through
the call_module method:
Passing memory blocks between Python data objects (e.g. numpy.ndarray,
pandas.Series, xarray.DataArray, etc) and GMT happens through
virtual files. These methods are context managers that automate the conversion of
Python objects to and from GMT virtual files:
Low level access (these are mostly used by the pygmt.clib package):
clib.Session.create(name)
|
Create a new GMT C API session. |
clib.Session.destroy()
|
Destroy the currently open GMT API session. |
clib.Session.__getitem__(name)
|
Get the value of a GMT constant. |
clib.Session.__enter__()
|
Create a GMT API session. |
clib.Session.__exit__(exc_type, exc_value, ...)
|
Destroy the currently open GMT API session. |
clib.Session.get_default(name)
|
Get the value of a GMT configuration parameter or a GMT API parameter. |
clib.Session.get_common(option)
|
Inquire if a GMT common option has been set and return its current value if possible. |
clib.Session.create_data(family, geometry, mode)
|
Create an empty GMT data container and allocate space to hold data. |
clib.Session.put_matrix(dataset, matrix[, pad])
|
Attach a 2-D numpy array to a GMT dataset. |
clib.Session.put_strings(dataset, family, ...)
|
Attach a 1-D numpy array of dtype str as a column on a GMT dataset. |
clib.Session.put_vector(dataset, column, vector)
|
Attach a 1-D numpy array as a column on a GMT dataset. |
clib.Session.read_data(infile, kind[, ...])
|
Read a data file into a GMT data container. |
clib.Session.write_data(family, geometry, ...)
|
Write a GMT data container to a file. |
clib.Session.open_virtualfile(family, ...)
|
Open a GMT virtual file associated with a data object for reading or writing. |
clib.Session.read_virtualfile(vfname[, kind])
|
Read data from a virtual file and optionally cast into a GMT data container. |
clib.Session.extract_region()
|
Extract the region of the currently active figure. |
clib.Session.get_libgmt_func(name[, ...])
|
Get a ctypes function from the libgmt shared library. |
clib.Session.virtualfile_from_grid(grid)
|
Store a grid in a virtual file. |
clib.Session.virtualfile_from_stringio(stringio)
|
Store a io.StringIO object in a virtual file. |
clib.Session.virtualfile_from_matrix(matrix)
|
Store a 2-D numpy array as a matrix inside a virtual file. |
clib.Session.virtualfile_from_vectors(vectors)
|
Store a sequence of 1-D vectors as columns of a dataset inside a virtual file. |
|