Text symbols

The pygmt.Figure.plot method allows to plot text symbols. Text is normally placed with the pygmt.Figure.text method but there are times we wish to treat a character or even a string as a plottable symbol. A text symbol can be drawn by passing lsize+tstring to the style parameter where size defines the size of the text symbol (note: the size is only approximate; no individual scaling is done for different characters) and string can be a letter or a text string (less than 256 characters). Optionally, you can append +ffont,outlinecolor to select a particular font [Default is FONT_ANNOT_PRIMARY] and outline color [Default is black] as well as +jjustify to change the justification [Default is CM]. For all supported fonts see Supported Fonts. The fill color of the text symbols can be set with the fill parameter, and the outline width can be customized with the pen parameter.

text symbols
import pygmt

fig = pygmt.Figure()

fig.basemap(region=[0, 8, 0, 3], projection="X12c/4c", frame=True)

pen = "1.5p"
# plot an uppercase "A" of size 3.5c, color fill is set to "dodgerblue3"
fig.plot(x=1, y=1.5, style="l3.5c+tA", fill="dodgerblue3", pen=pen)
# plot an "asterisk" of size 3.5c, color fill is set to "red3"
fig.plot(x=2.5, y=1, style="l3.5c+t*", fill="red3", pen=pen)
# plot an uppercase "Z" of size 3.5c and use the "Courier-Bold" font,
# color fill is set to "seagreen"
fig.plot(x=4, y=1.5, style="l3.5c+tZ+fCourier-Bold", fill="seagreen", pen=pen)
# plot a lowercase "s" of size 3.5c and use the "Times-Italic" font,
# color fill is set to "gold"
fig.plot(x=5.5, y=1.5, style="l3.5c+ts+fTimes-Italic", fill="gold", pen=pen)
# plot the pi symbol of size 3.5c, the outline color of the symbol is set to
# "darkorange", the color fill is set to "magenta4"
fig.plot(x=7, y=1.5, style="l3.5c+tπ+fdarkorange", fill="magenta4", pen=pen)

fig.show()

Total running time of the script: (0 minutes 0.134 seconds)

Gallery generated by Sphinx-Gallery