|
9 | 9 | import os
|
10 | 10 | import pygmt
|
11 | 11 |
|
12 |
| -######################################################################################## |
| 12 | +############################################################################### |
13 | 13 | # Basic map annotation
|
14 | 14 | # --------------------
|
15 | 15 | #
|
16 | 16 | # Text annotations can be added to a map using the :meth:`text` method of the
|
17 | 17 | # :class:`pygmt.Figure`.
|
18 | 18 | #
|
19 |
| -# Full details of the GMT6 command `text` can be found `here<https://docs.generic-mapping-tools.org/latest/text.html>`_. |
20 |
| -# The Python binding to this command is documented `here<https://www.pygmt.org/latest/api/generated/pygmt.Figure.text.html>`_. |
21 |
| -# |
22 | 19 | # Here we create a simple map and add an annotation using the ``text``, ``x``,
|
23 | 20 | # and ``y`` arguments to specify the annotation text and position in the
|
24 | 21 | # projection frame. ``text`` accepts 'str' types, while ``x``, and ``y``
|
|
37 | 34 |
|
38 | 35 | fig.show()
|
39 | 36 |
|
40 |
| -######################################################################################## |
| 37 | +############################################################################### |
41 | 38 | # Changing font style
|
42 | 39 | # -------------------
|
43 |
| -# The size, family/weight, and colour of an annotation can be specified using the ``font`` argument. |
| 40 | +# The size, family/weight, and colour of an annotation can be specified using |
| 41 | +# the ``font`` argument. |
44 | 42 | #
|
45 |
| -# A list of all recognised fonts can be found `here<https://docs.generic-mapping-tools.org/latest/cookbook/postscript_fonts.html>`_), |
46 |
| -# including details of how to use non-default fonts. |
| 43 | +# A list of all recognised fonts can be found at |
| 44 | +# :gmt-docs:`cookbook/postscript_fonts.html`, including details of how to use |
| 45 | +# non-default fonts. |
47 | 46 |
|
48 | 47 | fig = pygmt.Figure()
|
49 | 48 | with pygmt.config(MAP_FRAME_TYPE="plain"):
|
|
55 | 54 |
|
56 | 55 | fig.show()
|
57 | 56 |
|
58 |
| -######################################################################################## |
| 57 | +############################################################################### |
59 | 58 | # Plotting from a text file
|
60 | 59 | # -------------------------
|
61 | 60 | #
|
|
84 | 83 |
|
85 | 84 | fig.show()
|
86 | 85 |
|
87 |
| -######################################################################################## |
| 86 | +############################################################################### |
88 | 87 | # ``justify`` argument
|
89 | 88 | # --------------------
|
90 | 89 | #
|
|
108 | 107 | )
|
109 | 108 | fig.show()
|
110 | 109 |
|
111 |
| -######################################################################################## |
| 110 | +############################################################################### |
112 | 111 | # ``angle`` argument
|
113 | 112 | # ------------------
|
114 | 113 | # ``angle`` is an optional argument used to specify the clockwise rotation of
|
|
120 | 119 | fig.text(text=f"` {i} Degrees", x=2, y=2, justify="LM", angle=i)
|
121 | 120 | fig.show()
|
122 | 121 |
|
123 |
| -######################################################################################## |
124 |
| -# Additional arguments |
125 |
| -# -------------------- |
| 122 | +############################################################################### |
| 123 | +# ``fill`` argument |
| 124 | +# ----------------- |
126 | 125 | #
|
127 |
| -# Text can be further configured by passing an argument corresponding to the |
128 |
| -# flag names in GMT, following the same convention as described in the GMT |
129 |
| -# documentation. It is hoped that over time more bindings to these arguments |
130 |
| -# will be written into PyGMT. |
| 126 | +# ``fill`` is used to set the fill colour of the area surrounding the text. |
131 | 127 |
|
132 | 128 | fig = pygmt.Figure()
|
133 | 129 | fig.basemap(region=[0, 1, 0, 1], projection="X5c", frame="WSen")
|
134 |
| -fig.text(text="Green", x=0.5, y=0.5, G="green") |
| 130 | +fig.text(text="Green", x=0.5, y=0.5, fill="green") |
135 | 131 | fig.show()
|
| 132 | + |
| 133 | +############################################################################### |
| 134 | +# Advanced configuration |
| 135 | +# ---------------------- |
| 136 | +# |
| 137 | +# For crafting more advanced styles, be sure to check out the GMT documentation |
| 138 | +# at :gmt-docs:`text.html` and also the cookbook at |
| 139 | +# :gmt-docs:`cookbook/features.html#placement-of-text`. Good luck! |
0 commit comments