|
| 1 | +r""" |
| 2 | +Text symbols |
| 3 | +------------ |
| 4 | +The :meth:`pygmt.Figure.plot` method allows to plot text symbols. Text is |
| 5 | +normally placed with the :meth:`pygmt.Figure.text` method but there are times |
| 6 | +we wish to treat a character or even a string as a plottable symbol. |
| 7 | +A text symbol can be drawn by passing **l**\ *size*\ **+t**\ *string* to |
| 8 | +the ``style`` parameter where *size* defines the size of the text symbol |
| 9 | +(note: the size is only approximate; no individual scaling is done for |
| 10 | +different characters) and *string* can be a letter or a text string |
| 11 | +(less than 256 characters). Optionally, you can append **+f**\ *font* to |
| 12 | +select a particular font [Default is :gmt-term:`FONT_ANNOT_PRIMARY`] as well as |
| 13 | +**+j**\ *justify* to change the justification [Default is CM]. Outline |
| 14 | +and fill color of the text symbols can be customized via the ``pen`` |
| 15 | +and ``color`` parameters, respectively. |
| 16 | +
|
| 17 | +For all supported octal codes and fonts see the GMT cookbook |
| 18 | +:gmt-docs:`cookbook/octal-codes.html` and |
| 19 | +:gmt-docs:`cookbook/postscript-fonts.html`. |
| 20 | +""" |
| 21 | + |
| 22 | +import pygmt |
| 23 | + |
| 24 | +fig = pygmt.Figure() |
| 25 | + |
| 26 | +fig.basemap(region=[0, 8, 0, 3], projection="X12c/4c", frame=True) |
| 27 | + |
| 28 | +pen = "1.5p" |
| 29 | +# plot an uppercase "A" of size 3.5c, color fill is set to "dodgerblue3" |
| 30 | +fig.plot(x=1, y=1.5, style="l3.5c+tA", color="dodgerblue3", pen=pen) |
| 31 | +# plot an "asterisk" of size 3.5c, color fill is set to "red3" |
| 32 | +fig.plot(x=2.5, y=1, style="l3.5c+t*", color="red3", pen=pen) |
| 33 | +# plot an uppercase "Z" of size 3.5c and use the "Courier-Bold" font, |
| 34 | +# color fill is set to "seagreen" |
| 35 | +fig.plot(x=4, y=1.5, style="l3.5c+tZ+fCourier-Bold", color="seagreen", pen=pen) |
| 36 | +# plot a lowercase "s" of size 3.5c and use the "Times-Italic" font, |
| 37 | +# color fill is set to "gold" |
| 38 | +fig.plot(x=5.5, y=1.5, style="l3.5c+ts+fTimes-Italic", color="gold", pen=pen) |
| 39 | +# plot the pi symbol (\160 is octal code for pi) of size 3.5c, for this use |
| 40 | +# the "Symbol" font, color fill is set to "magenta4" |
| 41 | +fig.plot(x=7, y=1.5, style="l3.5c+t\160+fSymbol", color="magenta4", pen=pen) |
| 42 | + |
| 43 | +fig.show() |
0 commit comments