Frames, ticks, titles, and labels

Setting frame, ticks, title, etc., of the plot is handled by the -B parameter that most plotting modules contain like basemap.

Plot Frame

By default, GMT does not add a frame to your plot. For example, we can plot the coastlines of the world with a Mercator projection:

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
gmt end show
../../_images/0d6a6739ffc4ab6b4b79b0e994ab313a.png

To add the default GMT frame style to the plot, add f to the -B.

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
   gmt basemap -Bf
gmt end show
../../_images/e9ea479bd2d8b74ba6930265852ce89d.png

Tick labels

In GMT the tick labels are called annotations. Add them by passing a through the -B parameter:

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
   gmt basemap -Baf
gmt end show
../../_images/400319cd8ba088ace1c0e9bca287124a.png

Gridlines

Add automatic grid lines to the plot by adding g:

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
   gmt basemap -Bafg
gmt end show
../../_images/622dffbd69bc84ce7dceb5663a698252.png

Custom annotations and intervals

To adjust the step widths of annotations, frame, and grid lines we can add the desired step widths after a, f, or g. In the example below, the step widths are set to 30°, 7.5°, and 15°, respectively.

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
   gmt basemap -Ba30f7.5g15
gmt end show
../../_images/4024575257cabbea8030488db22256c4.png

Title

The figure title can be set by passing +ttitle:

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
   gmt basemap -Bafg
   gmt basemap -B+t"Mercator Map"
gmt end show
../../_images/18736ae188d169a16383b28a3a7afcb8.png

Subtitle

Then you can add a subtitle with +ssubtitle:

gmt begin frames png
   gmt coast -R-180/180/-60/60 -JM25c -W
   gmt basemap -Bafg
   gmt basemap -B+t"Mercator Map"+s"Subtitle"
gmt end show
../../_images/f179478fe64edee807e938e52a7a7944.png