This page was generated from doc/gallery/thumbnail-from-conf-py.ipynb. Interactive online version: Binder badge.

Specifying Thumbnails in conf.py

This notebook doesn’t contain a nbsphinx-thumbnail cell tag nor cell metadata. Instead, in the file conf.py, a thumbnail is specified (via the nbsphinx_thumbnails option), which will be used in the gallery.

The keys in the nbsphinx_thumbnails dictionary can contain wildcards, which behave very similarly to the html_sidebars option.

The thumbnail files can be local image files somewhere in the source directory, but you’ll need to create at least one link to them in order to copy them to the HTML output directory.

You can also use files from the _static directory (which contains all files in your html_static_path).

If you want, you can also use files from the _images directory, which contains all notebook outputs.

To demonstrate this feature, we are creating an image file here:

[1]:
import matplotlib.pyplot as plt
[2]:
fig, ax = plt.subplots()
ax.plot([4, 8, 15, 16, 23, 42])
fig.savefig('a-local-file.png')
plt.close()  # avoid plotting the figure

Please note that the previous cell doesn’t have any outputs, but it has generated a file named a-local-file.png in the notebook’s directory.

We have to create a link to this file (which is a good idea anyway): a-local-file.png.

Now we can use this file in our conf.py like this:

nbsphinx_thumbnails = {
    'gallery/thumbnail-from-conf-py': 'gallery/a-local-file.png',
}

Please note that the notebook name does not contain the .ipynb suffix.

Note that the following plot is not used as a thumbnail because the nbsphinx_thumbnails setting overrides the default behavior.

[3]:
fig, ax = plt.subplots(figsize=[6, 3])
ax.plot([4, 9, 7, 20, 6, 33, 13, 23, 16, 62, 8], 'r:');
../_images/gallery_thumbnail-from-conf-py_7_0.svg
Read the Docs v: pytorch-theme
Versions
latest
0.9.0
0.8.12
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.1
0.7.0
0.6.1
0.6.0
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.18
0.2.17
0.2.16
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
uedoc-theme
typlog-theme
traditional-theme
sphinxdoc-theme
sphinx-book-theme
sizzle-theme
scrolls-theme
save-rst
rtd-theme
pyviz-theme
pytorch-theme
python-docs-theme
pyramid-theme
pydata-theme
py3doc-enhanced-theme
pangeo-theme
pandas-theme
nature-theme
material-theme
maisie-theme
jupyter-theme
insipid-theme
holoviz-theme
haiku-theme
guzzle-theme
furo-theme
documatt-theme
dask-theme
cloud-theme
classic-theme
bootstrap-theme
bizstyle-theme
better-theme
basicstrap-theme
astropy-theme
alabaster-theme
agogo-theme
0.1.0
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

Docs

Lorem ipsum dolor sit amet, consectetur

View Docs

Tutorials

Lorem ipsum dolor sit amet, consectetur

View Tutorials

Resources

Lorem ipsum dolor sit amet, consectetur

View Resources