Frames, ticks, titles, and labels
Setting frame, ticks, title, etc., of the plot is handled by the
parameter that most plotting methods of the
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:
Ticks and grid lines
The automatic frame (
frame="af") adds the default GMT
frame style and automatically determines tick labels from the plot region.
In GMT the tick labels are called annotations.
Add automatic grid lines to the plot by passing
g through the
To adjust the step widths of annotations, frame, and grid lines we can
add the desired step widths after
g. In the example
below, the step widths are set to 30°, 7.5°, and 15°, respectively.
The figure title can be set by passing +ttitle to the
pygmt.Figure.basemap. Passing multiple arguments to
frame can be done by using a list, as show in the example below.
Axis labels, in GMT simply called labels, can be set by passing
x+llabel (or starting with y if
labeling the y-axis) to the
frame parameter of
pygmt.Figure.basemap. The map boundaries (or plot axes) are named as
West/west/left (W, w, l), South/south/bottom
(S, s, b), North/north/top (N, n, t), and
East/east/right (E, e, r) sides of a figure. If an upper-case
letter (W, S, N, E) is passed, the axis is plotted with
tick marks and annotations. The lower-case version
(w, s, n, e) plots the axis only with tick marks.
To only plot the axis pass l, b, t, r. By default
frame="af"), the West and the South axes are
plotted with both tick marks and annotations.
The example below uses a Cartesian projection, as GMT does not allow labels to be set for geographic maps.
Total running time of the script: ( 0 minutes 9.260 seconds)