#!/usr/bin/env python # coding: utf-8 # This notebook is part of the `nbsphinx` documentation: https://nbsphinx.readthedocs.io/. # # Specifying Thumbnails in `conf.py` # # This notebook doesn't contain any thumbnail metadata. # # But in the file [conf.py](../conf.py), # a thumbnail is specified (via the # [nbsphinx_thumbnails](../usage.ipynb#nbsphinx_thumbnails) # option), # which will be used in the [gallery](../subdir/gallery.ipynb). # # The keys in the `nbsphinx_thumbnails` dictionary can contain wildcards, # which behave very similarly to the # [html_sidebars](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-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](../markdown-cells.ipynb#Links-to-Local-Files) # 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](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-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: # In[ ]: get_ipython().run_line_magic('matplotlib', 'agg') # In[ ]: import matplotlib.pyplot as plt # In[ ]: fig, ax = plt.subplots() ax.plot([4, 8, 15, 16, 23, 42]) fig.savefig('a-local-file.png') # 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](a-local-file.png). # # Now we can use this file in our [conf.py](../conf.py) like this: # # ```python # nbsphinx_thumbnails = { # 'gallery/thumbnail-from-conf-py': 'gallery/a-local-file.png', # } # ``` # # Please note that the notebook name does *not* contain the `.ipynb` suffix.