Note
Click here to download the full example code or to run this example in your browser via Binder
Providing a figure for the thumbnail image¶
This example demonstrates how to provide a figure that is displayed as the
thumbnail. This is done by specifying the keyword-value pair
mkdocs_gallery_thumbnail_path = 'fig path'
as a comment somewhere below the
docstring in the example file. In this example, we specify that we wish the
figure demo.png
in the folder _static
to be used for the thumbnail.
import numpy as np
import matplotlib.pyplot as plt
# mkdocs_gallery_thumbnail_path = '_static/demo.png'
x = np.linspace(0, 4*np.pi, 301)
y1 = np.sin(x)
y2 = np.cos(x)
Plot 1¶
plt.figure()
plt.plot(x, y1, label='sin')
plt.plot(x, y2, label='cos')
plt.legend()
plt.show()
Out:
/home/runner/work/mkdocs-gallery/mkdocs-gallery/examples/plot_04b_provide_thumbnail.py:30: UserWarning:
FigureCanvasAgg is non-interactive, and thus cannot be shown
Plot 2¶
plt.figure()
plt.plot(x, y1, label='sin')
plt.plot(x, y2, label='cos')
plt.legend()
plt.xscale('log')
plt.yscale('log')
plt.show()
Out:
/home/runner/work/mkdocs-gallery/mkdocs-gallery/examples/plot_04b_provide_thumbnail.py:42: UserWarning:
FigureCanvasAgg is non-interactive, and thus cannot be shown
Total running time of the script: ( 0 minutes 0.551 seconds)
Download Python source code: plot_04b_provide_thumbnail.py