Skip to content

Commit 55ade6f

Browse files
authored
Choosing the thumbnail figures in tutorials (#826)
Description of proposed changes - Add comments # sphinx_gallery_thumbnail_number = X to tutorials and choose the best thumbnail images. - Mention # sphinx_gallery_thumbnail_number = X in the contributing guide
1 parent a828f73 commit 55ade6f

11 files changed

+24
-10
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ General guidelines for making a good gallery plot:
130130
dataset isn't available, open an issue requesting one and we'll work together to add
131131
it.
132132
* Add comments to explain things are aren't obvious from reading the code. Good: *Use a
133-
Mercator projection and make the plot 15 centimeters wide*. Bad: *Draw coastlines and
133+
Mercator projection and make the plot 15 centimeters wide*. Bad: *Draw coastlines and
134134
plot the data*.
135135
* Describe the feature that you're showcasing and link to other relevant parts of the
136136
documentation.
@@ -147,6 +147,9 @@ The tutorials (the User Guide in the docs) are also built by sphinx-gallery from
147147
* Include the tutorial in the table of contents of the documentation (side bar). Do this
148148
by adding a line to the User Guide `toc` directive in `doc/index.rst`. Notice that the
149149
file included is the `.rst` generated by sphinx-gallery.
150+
* Choose the most representative figure as the thumbnail figure by adding a comment line
151+
`# sphinx_gallery_thumbnail_number = <fig_number>` to any place (usually at the top)
152+
in the tutorial. The *fig_number* starts from 1.
150153

151154
Guidelines for a good tutorial:
152155

@@ -156,7 +159,7 @@ Guidelines for a good tutorial:
156159
features or abbreviations.
157160
* Explain the options and features in as much detail as possible. The gallery has
158161
concise examples while the tutorials are detailed and full of text.
159-
* SI units should be used in the example code for tutorial plots.
162+
* SI units should be used in the example code for tutorial plots.
160163

161164
Note that the `Figure.show()` function needs to be called for a plot to be inserted into
162165
the documentation.
@@ -165,15 +168,15 @@ the documentation.
165168

166169
When editing documentation, use the following standards to demonstrate the example code:
167170

168-
1. Python arguments, such as import statements, Boolean expressions, and function
171+
1. Python arguments, such as import statements, Boolean expressions, and function
169172
arguments should be wrapped as ``code`` by using \`\` on both sides of the code.
170173
Example: \`\`import pygmt\`\` results in ``import pygmt``
171-
172-
2. Literal GMT arguments should be **bold** by wrapping the arguments with \*\*
173-
(two asterisks) on both sides. The argument description should be in *italicized*
174+
175+
2. Literal GMT arguments should be **bold** by wrapping the arguments with \*\*
176+
(two asterisks) on both sides. The argument description should be in *italicized*
174177
with \* (single asterisk) on both sides.
175178
Example: `**+l**\ *label*` results in **+l***label*
176-
179+
177180
3. Optional arguments are placed wrapped with [ ] (square brackets).
178181
4. Arguments that are mutually exclusive are separated with a | (bar) to denote "or".
179182

@@ -319,9 +322,9 @@ existing functionality.
319322
Tests also help us be confident that we won't break your code in the future.
320323

321324
When writing tests, don't test everything that the GMT function already tests, such as
322-
the every unique combination arguments. An exception to this would be the most popular
323-
modules, such as `plot` and `basemap`. The highest priority for tests should be the
324-
Python-specific code, such as numpy, pandas, and xarray objects and the virtualfile
325+
the every unique combination arguments. An exception to this would be the most popular
326+
modules, such as `plot` and `basemap`. The highest priority for tests should be the
327+
Python-specific code, such as numpy, pandas, and xarray objects and the virtualfile
325328
mechanism.
326329

327330
If you're **new to testing**, see existing test files for examples of things to do.

doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
# Insert links to documentation of objects in the examples
9090
"reference_url": {"pygmt": None},
9191
"image_scrapers": (PyGMTScraper(),),
92+
# Removes configuration comments from scripts
93+
"remove_config_comments": True,
9294
}
9395

9496
# Sphinx project configuration

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Create 3-D perspective image or surface mesh from a grid
66
using :meth:`pygmt.Figure.grdview`.
77
"""
8+
# sphinx_gallery_thumbnail_number = 7
89

910
import pygmt
1011

examples/tutorials/coastlines.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
Plotting coastlines and borders is handled by :meth:`pygmt.Figure.coast`.
66
"""
7+
# sphinx_gallery_thumbnail_number = 5
78

89
import pygmt
910

examples/tutorials/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
Default GMT parameters can be set globally or locally using :class:`pygmt.config`.
66
"""
7+
# sphinx_gallery_thumbnail_number = 3
78

89
import pygmt
910

examples/tutorials/contour-map.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
Plotting a contour map is handled by :meth:`pygmt.Figure.grdcontour`.
66
"""
7+
# sphinx_gallery_thumbnail_number = 5
78

89
import pygmt
910

examples/tutorials/earth-relief.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:meth:`pygmt.datasets.load_earth_relief` method. The data can then be plotted using the
77
:meth:`pygmt.Figure.grdimage` method.
88
"""
9+
# sphinx_gallery_thumbnail_number = 5
910

1011
import pygmt
1112

examples/tutorials/frames.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Setting the style of the map frames, ticks, etc, is handled by the ``frame`` argument
66
that all plotting methods of :class:`pygmt.Figure`.
77
"""
8+
# sphinx_gallery_thumbnail_number = 4
89

910
import pygmt
1011

examples/tutorials/lines.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
Plotting lines is handled by :meth:`pygmt.Figure.plot`.
66
"""
7+
# sphinx_gallery_thumbnail_number = 3
78

89
import pygmt
910

examples/tutorials/plot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
automatically downloaded and saved to a cache directory the first time you use them
99
(usually ``~/.gmt/cache``).
1010
"""
11+
# sphinx_gallery_thumbnail_number = 3
1112

1213
import pygmt
1314

examples/tutorials/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
It is often useful to add annotations to a map plot. This is handled by
66
:meth:`pygmt.Figure.text`.
77
"""
8+
# sphinx_gallery_thumbnail_number = 3
89

910
import os
1011

0 commit comments

Comments
 (0)