Choosing the thumbnail of an example#

An example that draws more than once has to say which figure represents it in the gallery grid. Setting sphinx_gallery_thumbnail_number as a comment anywhere below the docstring picks a figure by the order it was drawn in; this example picks the second one.

import matplotlib.pyplot as plt
import numpy as np

try:
    import mplstyle_reslumen  # noqa: F401

    plt.style.use("reslumen")
except ImportError:
    pass
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()
thumbnail

Plot 2#

The one the gallery shows.

plt.figure()
plt.plot(x, y1, label="sin")
plt.plot(x, y2, label="cos")
plt.legend()
plt.xscale("log")
plt.yscale("log")
plt.show()
thumbnail

Total running time of the script: (0 minutes 0.239 seconds)