Frames, ticks, titles, and labels¶
Setting the style of the map frames, ticks, etc, is handled by the
that all plotting methods of
This tutorial assumes the use of a Python notebook, such as IPython or Jupyter Notebook.
To see the figures while using a Python script instead, use
fig.show(method="external") to display the figure in the default PDF viewer.
To save the figure, use
is the desired name and file extension for the saved figure.
By default, PyGMT does not add a frame to your plot. For example, we can plot the coastlines of the world with a Mercator projection:
To add the default GMT frame to the plot, use
pygmt.Figure.basemap or any other plotting module:
Ticks and grid lines¶
The automatic frame (
frame="a") sets the default GMT style frame
and automatically determines tick labels from the plot region.
Add automatic grid lines to the plot by adding a
The figure title can be set by passing +ttitle to the
frame parameter of
pygmt.Figure.basemap. Passing multiple arguments to
frame can be done by
using a list, as show in the example below.
To use a title with multiple words, the title must be placed inside another set of
quotation marks. To prevent the quotation marks from appearing in the figure title,
frame parameter can be passed in single quotation marks and the title can be
passed in double quotation marks.
Axis labels can be set by passing x+llabel (or starting with y if
labeling the y-axis) to the
frame parameter of
By default, all 4 map boundaries (or plot axes) are plotted with both tick marks and
axis labels. The axes are named as W (west/left), S (south/bottom),
N (north/top), and E (east/right) sides of a figure. If an upper-case axis
name is passed, the axis is plotted with tick marks and axis labels. A lower case
axis name plots only the axis and tick marks.
The example below uses a Cartesian projection, as GMT does not allow axis labels to be set for geographic maps.
Total running time of the script: ( 0 minutes 12.262 seconds)