Skip to content

Commit 153355e

Browse files
authored
Improve gallery examples (GenericMappingTools#827)
- Use SI units - Improve some comments - Improve some external references - Improve some stylings - Remove some links to the GMT documentation
1 parent 8e2b369 commit 153355e

10 files changed

+36
-42
lines changed

examples/gallery/coast/borders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import pygmt
1919

2020
fig = pygmt.Figure()
21-
# Make a Sinusoidal projection map of the Americas with automatic ticks
22-
fig.basemap(region=[-150, -30, -60, 60], projection="I-90/8i", frame="afg")
21+
# Make a Sinusoidal projection map of the Americas with automatic annotations, ticks and gridlines
22+
fig.basemap(region=[-150, -30, -60, 60], projection="I-90/15c", frame="afg")
2323
# Plot each level of the boundaries dataset with a different color.
2424
fig.coast(borders=["1/0.5p,black", "2/0.5p,red", "3/0.5p,blue"], land="gray")
2525
fig.show()

examples/gallery/coast/land_and_water.py

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

1111
fig = pygmt.Figure()
1212
# Make a global Mollweide map with automatic ticks
13-
fig.basemap(region="g", projection="W8i", frame=True)
14-
# Plot the land as light gray
13+
fig.basemap(region="g", projection="W15c", frame=True)
14+
# Plot the land as light gray, and the water as sky blue
1515
fig.coast(land="#666666", water="skyblue")
1616
fig.show()

examples/gallery/coast/shorelines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
fig = pygmt.Figure()
1010
# Make a global Mollweide map with automatic ticks
11-
fig.basemap(region="g", projection="W8i", frame=True)
11+
fig.basemap(region="g", projection="W15c", frame=True)
1212
# Display the shorelines as black lines with 0.5 point thickness
1313
fig.coast(shorelines="0.5p,black")
1414
fig.show()

examples/gallery/grid/grdview_surface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ def ackley(x, y):
3737
fig = pygmt.Figure()
3838

3939
# Plot grid as a 3-D surface
40-
SCALE = 0.2 # [inches]
40+
SCALE = 0.5 # in centimeter
4141
fig.grdview(
4242
data,
4343
frame=["a5f1", "za5f1"],
44-
projection=f"x{SCALE}i",
45-
zscale=f"{SCALE}i",
44+
projection=f"x{SCALE}c",
45+
zscale=f"{SCALE}c",
4646
surftype="s",
4747
cmap="roma",
4848
perspective=[135, 30], # Azimuth southeast (135°), at elevation 30°

examples/gallery/grid/track_sampling.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
55
The :func:`pygmt.grdtrack` function samples a raster grid's value along specified
66
points. We will need to input a 2D raster to ``grid`` which can be an
7-
``xarray.DataArray``. The ``points`` parameter can be a ``pandas.DataFrame`` table where
7+
:class:`xarray.DataArray`. The ``points`` argument can be a :class:`pandas.DataFrame` table where
88
the first two columns are x and y (or longitude and latitude). Note also that there is a
9-
``newcolname`` parameter that will be used to name the new column of values we sampled
9+
``newcolname`` argument that will be used to name the new column of values we sampled
1010
from the grid.
1111
1212
Alternatively, we can provide a NetCDF file path to ``grid``. An ASCII file path can
13-
also be accepted for ``points``, but an ``outfile`` parameter will then need to be set
13+
also be accepted for ``points``, but an ``outfile`` argument will then need to be set
1414
to name the resulting output ASCII file.
1515
"""
1616

@@ -24,10 +24,10 @@
2424

2525
fig = pygmt.Figure()
2626
# Plot the earth relief grid on Cylindrical Stereographic projection, masking land areas
27-
fig.basemap(region="g", frame=True, projection="Cyl_stere/150/-20/8i")
27+
fig.basemap(region="g", frame=True, projection="Cyl_stere/150/-20/15c")
2828
fig.grdimage(grid=grid, cmap="gray")
2929
fig.coast(land="#666666")
30-
# Plot using circles (c) of 0.15cm, the sampled bathymetry points
30+
# Plot using circles (c) of 0.15 cm, the sampled bathymetry points
3131
# Points are colored using elevation values (normalized for visual purposes)
3232
fig.plot(
3333
x=track.longitude,

examples/gallery/plot/colorbar.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55
The :meth:`pygmt.Figure.colorbar` method creates a color scalebar. We must
66
specify the colormap via the ``cmap`` argument, and optionally set the
77
placement via the ``position`` argument. The full list of color palette tables
8-
can be found at :gmt-docs:`cookbook/cpts.html`. You can set the `position` of
8+
can be found at :gmt-docs:`cookbook/cpts.html`. You can set the ``position`` of
99
the colorbar using the following options:
1010
11-
- j/J: justified inside/outside the map frame using any 2 character combination
12-
of vertical (**T** op, **M** iddle, **B** ottom) and horizontal (**L** eft,
13-
**C** enter, **R** ight) alignment codes, e.g. `position="jTR"` for top
11+
- **j/J**: justified inside/outside the map frame using any 2 character combination
12+
of vertical (**T**\ op, **M**\ iddle, **B**\ ottom) and horizontal (**L**\ eft,
13+
**C**\ enter, **R**\ ight) alignment codes, e.g. ``position="jTR"`` for top
1414
right.
15-
- g: using map coordinates, e.g. `position="g170/-45"` for longitude 170E,
15+
- **g**: using map coordinates, e.g. ``position="g170/-45"`` for longitude 170E,
1616
latitude 45S.
17-
- x: using paper coordinates, e.g. `position="x5c/7c"` for 5cm,7cm from anchor
17+
- **x**: using paper coordinates, e.g. ``position="x5c/7c"`` for 5cm,7cm from anchor
1818
point.
19-
- n: using normalized (0-1) coordinates, e.g. `position="n0.4/0.8"`.
19+
- **n**: using normalized (0-1) coordinates, e.g. ``position="n0.4/0.8"``.
2020
21-
Note that the anchor point defaults to the bottom left (BL). Append +h to
22-
``position`` to get a horizontal colorbar instead of a vertical one. For more
23-
advanced styling options, see the full option list at
24-
:gmt-docs:`colorbar.html`.
21+
Note that the anchor point defaults to the bottom left (BL). Append ``+h`` to
22+
``position`` to get a horizontal colorbar instead of a vertical one.
2523
"""
2624
import pygmt
2725

examples/gallery/plot/image.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
"""
22
Images or EPS files on maps
33
---------------------------
4-
The :meth:`pygmt.Figure.image` method can be used to read and
4+
The :meth:`pygmt.Figure.image` method can be used to read and
55
place a raster image file or an Encapsulated PostScript file
6-
on a map. We must specify the file as *str* via the ``imagefile``
7-
argument or simply use the filename as first argument. You can
8-
also use a full URL pointing to your desired image. The ``position``
6+
on a map. We must specify the file as *str* via the ``imagefile``
7+
argument or simply use the filename as the first argument. You can
8+
also use a full URL pointing to your desired image. The ``position``
99
argument allows us to set a reference point on the map for the image.
1010
11-
For more advanced style options, see the full option list
12-
at :gmt-docs:`image.html`.
1311
"""
1412

1513
import pygmt

examples/gallery/plot/meca.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
land="grey",
2121
water="lightblue",
2222
shorelines=True,
23-
resolution="f",
2423
frame="a",
2524
)
2625

examples/gallery/plot/multi-parameter-symbols.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
Multi-parameter symbols
33
-------------------------
44
5-
The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter symbols by passing
6-
the corresponding shortcuts listed below to the ``style`` argument. Additionally, we must define
7-
the required parameters in a 2d list or numpy array (``[[parameters]]`` for a single symbol
8-
or ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an
9-
appropriately formatted input file and pass it to ``data``.
5+
The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter symbols by passing
6+
the corresponding shortcuts listed below to the ``style`` argument. Additionally, we must define
7+
the required parameters in a 2d list or numpy array (``[[parameters]]`` for a single symbol
8+
or ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an
9+
appropriately formatted input file and pass it to ``data``.
1010
1111
The following symbols are available:
1212
1313
- **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]``
1414
- **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]``
1515
- **r**: rectangle, ``[[lon, lat, width, height]]``
1616
- **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]``
17-
- **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two arguments are
18-
directions given in degrees counter-clockwise from horizontal
17+
- **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two arguments are
18+
directions given in degrees counter-clockwise from horizontal
1919
20-
Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and **w** but expect geographic
20+
Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and **w** but expect geographic
2121
azimuths and distances.
2222
23-
For more advanced options, see the full option list at :gmt-docs:`plot.html`.
2423
"""
2524

2625
import numpy as np

examples/gallery/plot/points.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
y = np.random.uniform(region[2], region[3], 100)
1616

1717
fig = pygmt.Figure()
18-
# Create a 6x6 inch basemap with a Cartesian projection (X) using the data region
19-
fig.basemap(region=region, projection="X6i", frame=True)
18+
# Create a 15x15 cm basemap with a Cartesian projection (X) using the data region
19+
fig.basemap(region=region, projection="X15c", frame=True)
2020
# Plot using triangles (i) of 0.5 cm
2121
fig.plot(x, y, style="i0.5c", color="black")
2222
fig.show()

0 commit comments

Comments
 (0)