Skip to content

Commit dfb231a

Browse files
willschlitzerseismanweiji14
authored
Add an "add a title" to starter tutorial (#1688)
Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Wei Ji <[email protected]>
1 parent 0ddbf8b commit dfb231a

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

examples/get-started/first_figure.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@
121121
# annotate the latitude and longitude of the region.
122122
#
123123
# The ``frame`` parameter is used to add a frame to the figure. For now, it
124-
# will be set to ``True`` to use default settings, but later tutorials will
125-
# show how ``frame`` can be used to customize the axes, gridlines, and titles.
124+
# will be set to ``"a"`` to **a**\ nnotate the axes automatically.
126125

127126
fig = pygmt.Figure()
128127
fig.coast(
@@ -131,7 +130,34 @@
131130
land="lightgreen",
132131
water="lightblue",
133132
projection="M10c",
134-
frame=True,
133+
frame="a",
134+
)
135+
fig.show()
136+
137+
###############################################################################
138+
# Add a title
139+
# -----------
140+
#
141+
# The ``frame`` parameter can be used to add a title to the figure. The title
142+
# is set with by passing ``"+t"`` followed by the title (e.g. setting the map
143+
# title to "Title" would be ``"+tTitle"``).
144+
#
145+
# To pass multiple arguments to ``frame``, a list can be used, as shown in the
146+
# example below. This format uses ``frame`` to set both the axes gridlines and
147+
# the figure title.
148+
#
149+
# If the figure title has any spaces, the string to set the title needs to
150+
# be wrapped in single-quotes, while the actual title is set in double quotes
151+
# (e.g. setting the title to "A Title" would use the syntax ``'+t"A Title"'``.
152+
153+
fig = pygmt.Figure()
154+
fig.coast(
155+
region=[-69, -68, 43.75, 44.75],
156+
shorelines=True,
157+
land="lightgreen",
158+
water="lightblue",
159+
projection="M10c",
160+
frame=["a", "+tMaine"],
135161
)
136162
fig.show()
137163

0 commit comments

Comments
 (0)