pygmt.Figure.legend

Figure.legend(self, spec=None, **kwargs)

Plot legends on maps.

Makes legends that can be overlaid on maps. Reads specific legend-related information from either a) an input file or b) a list containing a list of figure handles and a list of corresponding labels. Unless otherwise noted, annotations will be made using the primary annotation font and size in effect (i.e., FONT_ANNOT_PRIMARY).

Full option list at https://www.generic-mapping-tools.org/gmt/latest/legend.html

Aliases:

  • D = position
  • F = box
  • J = projection
  • R = region
Parameters:
spec : None or str

Either None (default) for using the automatically generated legend specification file, or a filename pointing to the legend specification file.

J : str

Required if this is the first plot command. Select map projection.

R : str or list

Required if this is the first plot command. 'xmin/xmax/ymin/ymax[+r][+uunit]'. Specify the region of interest.

position (D) : str

'[g|j|J|n|x]refpoint+wwidth[/height][+jjustify][+lspacing][+odx[/dy]]' Defines the reference point on the map for the legend.

box (F) : bool or str

'[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]]' Without further options, draws a rectangular border around the legend using MAP_FRAME_PEN.