Skip to content

Commit 7e83aef

Browse files
Style and formatting fixes for tutorials (#818)
*Update tutorials to use the term "arguments" when referring to PyGMT inputs *Standardize and clean up GMT arguments and PyGMT code in doc strings *Change line plotting tutorial file name and update index Co-authored-by: Will Schlitzer <[email protected]>
1 parent a2fb728 commit 7e83aef

File tree

9 files changed

+52
-51
lines changed

9 files changed

+52
-51
lines changed

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
tutorials/coastlines.rst
3434
tutorials/regions.rst
3535
tutorials/plot.rst
36-
tutorials/plot-lines.rst
36+
tutorials/lines.rst
3737
tutorials/text.rst
3838
tutorials/contour-map.rst
3939
tutorials/earth-relief.rst

examples/tutorials/3d-perspective-image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
########################################################################################
122122
# :meth:`pygmt.Figure.colorbar` can be used to add a color bar to the figure. The
123123
# ``cmap`` argument does not need to be passed again. To keep the color bar's alignment
124-
# similar to the figure, use **True** as the ``perspective`` argument.
124+
# similar to the figure, use ``True`` as the ``perspective`` argument.
125125

126126
fig = pygmt.Figure()
127127
fig.grdview(

examples/tutorials/coastlines.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Use the ``shorelines`` argument to plot only the shorelines:
1515

1616
fig = pygmt.Figure()
17-
fig.basemap(region="g", projection="W10i", frame=True)
17+
fig.basemap(region="g", projection="W15c", frame=True)
1818
fig.coast(shorelines=True)
1919
fig.show()
2020

@@ -31,7 +31,7 @@
3131
# lines:
3232

3333
fig = pygmt.Figure()
34-
fig.basemap(region="g", projection="W10i", frame=True)
34+
fig.basemap(region="g", projection="W15c", frame=True)
3535
fig.coast(shorelines="1/0.5p,black")
3636
fig.show()
3737

@@ -40,7 +40,7 @@
4040
# ``shorelines``:
4141

4242
fig = pygmt.Figure()
43-
fig.basemap(region="g", projection="W10i", frame=True)
43+
fig.basemap(region="g", projection="W15c", frame=True)
4444
fig.coast(shorelines=["1/1p,black", "2/0.5p,red"])
4545
fig.show()
4646

@@ -60,15 +60,15 @@
6060
oahu = [-158.3, -157.6, 21.2, 21.8]
6161
fig = pygmt.Figure()
6262
for res in ["c", "l", "i", "h", "f"]:
63-
fig.coast(resolution=res, shorelines="1p", region=oahu, projection="M5i")
64-
fig.shift_origin(xshift="5i")
63+
fig.coast(resolution=res, shorelines="1p", region=oahu, projection="M5c")
64+
fig.shift_origin(xshift="5c")
6565
fig.show()
6666

6767
########################################################################################
6868
# Land and water
6969
# --------------
7070
#
71-
# Use the ``land`` and ``water`` attributes to specify a fill color for land and water
71+
# Use the ``land`` and ``water`` arguments to specify a fill color for land and water
7272
# bodies. The colors can be given by name or hex codes (like the ones used in HTML and
7373
# CSS):
7474

examples/tutorials/earth-relief.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pygmt
1111

1212
########################################################################################
13-
# Load sample Earth relief data for the entire globe at a resolution of 30 minutes.
13+
# Load sample Earth relief data for the entire globe at a resolution of 30 arc minutes.
1414
# The other available resolutions are show at :gmt-docs:`datasets/remote-data.html#global-earth-relief-grids`.
1515
grid = pygmt.datasets.load_earth_relief(resolution="30m")
1616

@@ -30,7 +30,7 @@
3030
########################################################################################
3131
#
3232
# :meth:`pygmt.Figure.grdimage` can take the optional argument ``projection`` for the
33-
# map. In the example below, the ``projection`` is set as ``"R12c"`` for 12 centimeter
33+
# map. In the example below, the ``projection`` is set as ``R12c`` for 12 centimeter
3434
# figure with a Winkel Tripel projection. For a list of available projections,
3535
# see :gmt-docs:`cookbook/map-projections.html`.
3636

@@ -71,8 +71,8 @@
7171
# for :meth:`pygmt.Figure.grdimage`. The ``frame`` argument for
7272
# :meth:`pygmt.Figure.colorbar` can be used to set the axis intervals and labels. A
7373
# list is used to pass multiple arguments to ``frame``. In the example below,
74-
# ``"a2500"`` sets the axis interval to 2,500, ``"x+lElevation"`` sets the x-axis
75-
# label, and ``"y+lm"`` sets the y-axis label.
74+
# ``a2500`` sets the axis interval to 2,500, ``x+lElevation`` sets the x-axis
75+
# label, and ``y+lm`` sets the y-axis label.
7676

7777
fig = pygmt.Figure()
7878
fig.grdimage(grid=grid, projection="R12c", cmap="geo")
@@ -85,11 +85,11 @@
8585
#
8686
# In addition to providing global data, the ``region`` argument for
8787
# :meth:`pygmt.datasets.load_earth_relief` can be used to provide data for a specific
88-
# area. The ``region`` argument is required for resolutions at 5 minutes or higher, and
88+
# area. The ``region`` argument is required for resolutions at 5 arc minutes or higher, and
8989
# accepts a list (as in the example below) or a string. The geographic ranges are
90-
# passed as *x-min*/*x-max*/*y-min*/*y-max*.
90+
# passed as *xmin*/*xmax*/*ymin*/*ymax*.
9191
#
92-
# The example below uses data with a 5 minute resolution, and plots it on a
92+
# The example below uses data with a 5 arc minute resolution, and plots it on a
9393
# 15 centimeter figure with a Mercator projection and a CPT set to *geo*.
9494
# ``frame="a"`` is used to add a frame to the figure.
9595

examples/tutorials/frames.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# Title
5353
# -----
5454
#
55-
# The figure title can be set by passing **+t**\ *title* to the ``frame`` parameter of
55+
# The figure title can be set by passing **+t**\ *title* to the ``frame`` argument of
5656
# :meth:`pygmt.Figure.basemap`. Passing multiple arguments to ``frame`` can be done by
5757
# using a list, as show in the example below.
5858

@@ -65,7 +65,7 @@
6565
########################################################################################
6666
# To use a title with multiple words, the title must be placed inside another set of
6767
# quotation marks. To prevent the quotation marks from appearing in the figure title,
68-
# the frame argument can be passed in single quotation marks and the title can be
68+
# the ``frame`` argument can be passed in single quotation marks and the title can be
6969
# passed in double quotation marks.
7070

7171
fig = pygmt.Figure()
@@ -78,15 +78,15 @@
7878
# Axis labels
7979
# -----------
8080
#
81-
# Axis labels can be set by passing **x+l**\ *label* (or starting with y if
82-
# labeling the y-axis) if to the ``frame`` parameter of :meth:`pygmt.Figure.basemap`.
81+
# Axis labels can be set by passing **x+l**\ *label* (or starting with **y** if
82+
# labeling the y-axis) to the ``frame`` argument of :meth:`pygmt.Figure.basemap`.
8383
# Axis labels will be displayed on all primary axes, which the default is all sides of
8484
# the figure. To designate only some of the axes as primary, an argument that
8585
# capitlizes only the primary axes can be passed, which is ``"WSne"`` in the example
8686
# below. The letters correspond with west (left), south (bottom), north (top), and
8787
# east (right) sides of a figure.
8888
#
89-
# The example below used a Cartesian projection, as GMT does not allow axis labels to
89+
# The example below uses a Cartesian projection, as GMT does not allow axis labels to
9090
# be set for geographic maps.
9191

9292
fig = pygmt.Figure()

examples/tutorials/plot-lines.py renamed to examples/tutorials/lines.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Plot lines
1212
# ----------
1313
#
14-
# Create a Cartesian figure using ``projection`` parameter and set the axis scales
14+
# Create a Cartesian figure using ``projection`` argument and set the axis scales
1515
# using ``region`` (in this case, each axis is 0-10). Pass a list of ``x`` and ``y``
1616
# values to be plotted as a line.
1717

@@ -43,7 +43,7 @@
4343

4444
########################################################################################
4545
# To plot multiple lines, :meth:`pygmt.Figure.plot` needs to be used for each
46-
# additional line. Parameters such as ``region``, ``projection``, and ``frame`` do
46+
# additional line. Arguments such as ``region``, ``projection``, and ``frame`` do
4747
# not need to be repeated in subsequent uses.
4848

4949
fig = pygmt.Figure()
@@ -62,11 +62,11 @@
6262
# Change line attributes
6363
# ----------------------
6464
#
65-
# The line attributes can be set using the ``pen`` parameter. ``pen`` takes a string
65+
# The line attributes can be set by the ``pen`` argument. ``pen`` takes a string
6666
# argument with the optional values *width*,\ *color*,\ *style*.
6767
#
68-
# In the example below, the pen width is set to ``"5p"``, and with *black* as the
69-
# default color and *solid* as the default style.
68+
# In the example below, the pen width is set to ``5p``, and with ``black`` as the
69+
# default color and ``solid`` as the default style.
7070

7171
fig = pygmt.Figure()
7272
fig.plot(
@@ -81,7 +81,7 @@
8181

8282
########################################################################################
8383
# The line color can be set and is added after the line width to the ``pen`` argument.
84-
# In the example below, the line color is set to "red".
84+
# In the example below, the line color is set to ``red``.
8585

8686
fig = pygmt.Figure()
8787
fig.plot(
@@ -96,8 +96,8 @@
9696

9797
########################################################################################
9898
# The line style can be set and is added after the line width or color to the
99-
# ``pen`` argument. In the example below, the line color is set to *dot dot dash*, and
100-
# the default color *black* is used.
99+
# ``pen`` argument. In the example below, the line style is set to
100+
# ``..-`` (*dot dot dash*), and the default color ``black`` is used.
101101

102102
fig = pygmt.Figure()
103103
fig.plot(
@@ -112,8 +112,8 @@
112112

113113
########################################################################################
114114
# The line width, color, and style can all be set in the same ``pen`` argument. In the
115-
# example below, the line width is set to *7p*, the color is set to *green*, and the
116-
# line style is *dash dot dash*.
115+
# example below, the line width is set to ``7p``, the color is set to ``green``, and the
116+
# line style is ``-.-`` (*dash dot dash*).
117117
#
118118
# For a gallery showing other ``pen`` settings, see :doc:`/gallery/line/linestyles`.
119119

examples/tutorials/plot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@
3535
# hypocenters of the earthquakes.
3636

3737
fig = pygmt.Figure()
38-
fig.basemap(region=region, projection="M8i", frame=True)
38+
fig.basemap(region=region, projection="M15c", frame=True)
3939
fig.coast(land="black", water="skyblue")
4040
fig.plot(x=data.longitude, y=data.latitude, style="c0.3c", color="white", pen="black")
4141
fig.show()
4242

4343
########################################################################################
4444
# We used the style ``c0.3c`` which means "circles of 0.3 centimeter size". The ``pen``
45-
# attribute controls the outline of the symbols and the ``color`` controls the fill.
45+
# argument controls the outline of the symbols and the ``color`` controls the fill.
4646
#
4747
# We can map the size of the circles to the earthquake magnitude by passing an array to
4848
# the ``sizes`` argument. Because the magnitude is on a logarithmic scale, it helps to
4949
# show the differences by scaling the values using a power law.
5050

5151
fig = pygmt.Figure()
52-
fig.basemap(region=region, projection="M8i", frame=True)
52+
fig.basemap(region=region, projection="M15c", frame=True)
5353
fig.coast(land="black", water="skyblue")
5454
fig.plot(
5555
x=data.longitude,
@@ -76,7 +76,7 @@
7676
#
7777

7878
fig = pygmt.Figure()
79-
fig.basemap(region=region, projection="M8i", frame=True)
79+
fig.basemap(region=region, projection="M15c", frame=True)
8080
fig.coast(land="black", water="skyblue")
8181
pygmt.makecpt(cmap="viridis", series=[data.depth_km.min(), data.depth_km.max()])
8282
fig.plot(

examples/tutorials/regions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# -----------
1515
#
1616
# A string of coordinates can be passed to ``region``, in the form of
17-
# *xmin*\ /*xmax*\ /*ymin*\ /*ymax*\ .
17+
# *xmin*/*xmax*/*ymin*/*ymax*.
1818

1919
fig = pygmt.Figure()
2020
fig.coast(
@@ -26,19 +26,19 @@
2626
land="lightgray",
2727
# Set the color of the water to white
2828
water="white",
29-
# Display the national borders and set the pen-size to 0.5p
29+
# Display the national borders and set the pen thickness to 0.5p
3030
borders="1/0.5p",
31-
# Display the shorelines and set the pen-size to 0.5p
31+
# Display the shorelines and set the pen thickness to 0.5p
3232
shorelines="1/0.5p",
33-
# Set the frame to automatic and display gridlines
33+
# Set the frame to display annotations and gridlines
3434
frame="ag",
3535
)
3636
fig.show()
3737

3838
########################################################################################
3939
#
40-
# The coordinates coordinates can be passed to ``region`` as a list, in the form
41-
# of [*xmin*\ ,\ *xmax*\ ,\ *ymin*\ ,\ *ymax*\ ].
40+
# The coordinates can be passed to ``region`` as a list, in the form
41+
# of [*xmin*,\ *xmax*,\ *ymin*,\ *ymax*].
4242

4343
fig = pygmt.Figure()
4444
fig.coast(
@@ -81,7 +81,7 @@
8181
# region to the entire globe. The range is 180W to 180E (-180, 180) and 90S to
8282
# 90N (-90 to 90). With no parameters set for the projection, the figure defaults to be
8383
# centered at the mid-point of both x- and y-axes. Using **d**\ , the figure is
84-
# centered at 0,0, or the intersection of the equator and prime meridian.
84+
# centered at (0, 0), or the intersection of the equator and prime meridian.
8585

8686
fig = pygmt.Figure()
8787
fig.coast(
@@ -99,7 +99,7 @@
9999
#
100100
# The argument **g** can be passed, which encompasses the entire globe. The range is
101101
# 0E to 360E (0, 360) and 90S to 90N (-90 to 90). With no parameters set for the
102-
# projection, the figure is centered at 180,0, or the intersection of the equator and
102+
# projection, the figure is centered at (180, 0), or the intersection of the equator and
103103
# International Date Line.
104104

105105
fig = pygmt.Figure()
@@ -159,7 +159,7 @@
159159
########################################################################################
160160
#
161161
# Instead of expanding the range of the plot uniformly in all directions, two values
162-
# can be passed to expand differently on each axis. The format is *xinc*\ /\ *yinc*.
162+
# can be passed to expand differently on each axis. The format is *xinc*/*yinc*.
163163

164164
fig = pygmt.Figure()
165165
fig.coast(
@@ -179,7 +179,7 @@
179179
#
180180
# Instead of expanding the range of the plot uniformly in all directions, four values
181181
# can be passed to expand differently in each direction.
182-
# The format is *winc*\ /\ *einc*\ /\ *sinc*\ /\ *ninc*\ , which expands on the west,
182+
# The format is *winc*/*einc*/*sinc*/*ninc*, which expands on the west,
183183
# east, south, and north axes.
184184

185185
fig = pygmt.Figure()

examples/tutorials/text.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#
2020
# Here we create a simple map and add an annotation using the ``text``, ``x``,
2121
# and ``y`` arguments to specify the annotation text and position in the
22-
# projection frame. ``text`` accepts 'str' types, while ``x``, and ``y``
23-
# accepts either 'int'/'float' numbers, or a list/array of numbers.
22+
# projection frame. ``text`` accepts *str* types, while ``x``, and ``y``
23+
# accepts either *int* or *float* numbers, or a list/array of numbers.
2424

2525
fig = pygmt.Figure()
2626
with pygmt.config(MAP_FRAME_TYPE="plain"):
@@ -59,8 +59,8 @@
5959
# Plotting from a text file
6060
# -------------------------
6161
#
62-
# It is also possible to add annotations from a file containing `x`, `y`, and
63-
# `text` fields. Here we give a complete example.
62+
# It is also possible to add annotations from a file containing ``x``, ``y``, and
63+
# ``text`` fields. Here we give a complete example.
6464

6565
fig = pygmt.Figure()
6666
with pygmt.config(MAP_FRAME_TYPE="plain"):
@@ -78,7 +78,7 @@
7878

7979
# Plot region names / sea names from a text file, where
8080
# the longitude (x) and latitude (y) coordinates are in the first two columns.
81-
# Setting angle/font/justiry to True will indicate that those columns are
81+
# Setting angle/font/justify to ``True`` will indicate that those columns are
8282
# present in the text file too (Note: must be in that order!).
8383
# Finally, the text to be printed will be in the last column
8484
fig.text(textfiles="examples.txt", angle=True, font=True, justify=True)
@@ -98,8 +98,9 @@
9898
#
9999
# The anchor is specified with a two letter (order independent) code, chosen
100100
# from:
101-
# * Vertical anchor: T(op), M(iddle), B(ottom)
102-
# * Horizontal anchor: L(eft), C(entre), R(ight)
101+
#
102+
# * Vertical anchor: **T**\(op), **M**\(iddle), **B**\(ottom)
103+
# * Horizontal anchor: **L**\(eft), **C**\(entre), **R**\(ight)
103104

104105
fig = pygmt.Figure()
105106
fig.basemap(region=[0, 3, 0, 3], projection="X10c", frame=["WSne", "af0.5g"])

0 commit comments

Comments
 (0)