Skip to content

Commit 3dde4b0

Browse files
committed
Use fill instead of G, and point advanced users to GMT cookbook
1 parent 20994aa commit 3dde4b0

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

examples/tutorials/text.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
import os
1010
import pygmt
1111

12-
########################################################################################
12+
###############################################################################
1313
# Basic map annotation
1414
# --------------------
1515
#
1616
# Text annotations can be added to a map using the :meth:`text` method of the
1717
# :class:`pygmt.Figure`.
1818
#
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-
#
2219
# Here we create a simple map and add an annotation using the ``text``, ``x``,
2320
# and ``y`` arguments to specify the annotation text and position in the
2421
# projection frame. ``text`` accepts 'str' types, while ``x``, and ``y``
@@ -37,13 +34,15 @@
3734

3835
fig.show()
3936

40-
########################################################################################
37+
###############################################################################
4138
# Changing font style
4239
# -------------------
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.
4442
#
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.
4746

4847
fig = pygmt.Figure()
4948
with pygmt.config(MAP_FRAME_TYPE="plain"):
@@ -55,7 +54,7 @@
5554

5655
fig.show()
5756

58-
########################################################################################
57+
###############################################################################
5958
# Plotting from a text file
6059
# -------------------------
6160
#
@@ -84,7 +83,7 @@
8483

8584
fig.show()
8685

87-
########################################################################################
86+
###############################################################################
8887
# ``justify`` argument
8988
# --------------------
9089
#
@@ -108,7 +107,7 @@
108107
)
109108
fig.show()
110109

111-
########################################################################################
110+
###############################################################################
112111
# ``angle`` argument
113112
# ------------------
114113
# ``angle`` is an optional argument used to specify the clockwise rotation of
@@ -120,16 +119,21 @@
120119
fig.text(text=f"` {i} Degrees", x=2, y=2, justify="LM", angle=i)
121120
fig.show()
122121

123-
########################################################################################
124-
# Additional arguments
125-
# --------------------
122+
###############################################################################
123+
# ``fill`` argument
124+
# -----------------
126125
#
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.
131127

132128
fig = pygmt.Figure()
133129
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")
135131
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

Comments
 (0)