Skip to content

Commit b925e3e

Browse files
Add sphinx_gallery_thumbnail_path for gallery examples missing thumbnails
Adds thumbnails for sgskip examples and non-figure-producing examples that are missing auto-generated gallery thumbnails. Partially addresses matplotlib#17479
1 parent 43a97ee commit b925e3e

10 files changed

Lines changed: 534 additions & 122 deletions

‎galleries/examples/animation/frame_grabbing_sgskip.py‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
file. This avoids any event loop integration, and thus works even with the Agg
88
backend. This is not recommended for use in an interactive setting.
99
"""
10-
1110
# sphinx_gallery_thumbnail_path = "_static/frame_grabbing.png"
11+
12+
1213
import numpy as np
1314

1415
import matplotlib
@@ -22,18 +23,21 @@
2223
np.random.seed(19680801)
2324

2425

25-
metadata = dict(title='Movie Test', artist='Matplotlib')
26+
metadata = dict(title='Movie Test', artist='Matplotlib',
27+
comment='Movie support!')
2628
writer = FFMpegWriter(fps=15, metadata=metadata)
2729

28-
fig, ax = plt.subplots()
29-
l0, = ax.plot([], [], color='C0', label='moving line')
30-
l1, = ax.plot([], [], color='C1', label='moving circle')
31-
ax.legend()
32-
ax.set(xlim=[-1, 1], ylim=[-1, 1])
30+
fig = plt.figure()
31+
l, = plt.plot([], [], 'k-o')
32+
33+
plt.xlim(-5, 5)
34+
plt.ylim(-5, 5)
35+
36+
x0, y0 = 0, 0
3337

3438
with writer.saving(fig, "writer_test.mp4", 100):
3539
for i in range(100):
36-
l0.set_data(np.linspace(-1, 1, 100),
37-
np.sin(2 * np.pi * (i / 100) + np.linspace(-1, 1, 100) * 2 * np.pi))
38-
l1.set_data(np.cos(2 * np.pi * i / 100), np.sin(2 * np.pi * i / 100))
40+
x0 += 0.1 * np.random.randn()
41+
y0 += 0.1 * np.random.randn()
42+
l.set_data([x0], [y0])
3943
writer.grab_frame()

‎galleries/examples/event_handling/ginput_manual_clabel_sgskip.py‎

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,89 @@
1414
You can copy and paste individual parts, or download the entire example
1515
using the link at the bottom of the page.
1616
"""
17-
1817
# sphinx_gallery_thumbnail_path = "_static/ginput_manual_clabel.png"
19-
import matplotlib.pyplot as plt
20-
import numpy as np
2118

22-
t = np.arange(0.0, 5.0, 0.01)
23-
s = np.cos(2 * np.pi * t)
24-
fig, ax = plt.subplots()
25-
ax.plot(t, s)
2619

27-
np.random.seed(19680801)
20+
import time
21+
22+
import matplotlib.pyplot as plt
23+
import numpy as np
2824

2925

3026
def tellme(s):
3127
print(s)
3228
plt.title(s, fontsize=16)
3329
plt.draw()
3430

35-
# Set up a figure, wait for input, and highlight the selected point.
31+
# %%
32+
# Define a triangle by clicking three points
33+
3634

37-
tellme('Click to begin')
35+
plt.figure()
36+
plt.xlim(0, 1)
37+
plt.ylim(0, 1)
38+
39+
tellme('You will define a triangle, click to begin')
3840

3941
plt.waitforbuttonpress()
4042

4143
while True:
4244
pts = []
43-
tellme('Select two corners of zoom, enter to start')
44-
pts = np.asarray(plt.ginput(2, timeout=-1))
45+
while len(pts) < 3:
46+
tellme('Select 3 corners with mouse')
47+
pts = np.asarray(plt.ginput(3, timeout=-1))
48+
if len(pts) < 3:
49+
tellme('Too few points, starting over')
50+
time.sleep(1) # Wait a second
51+
52+
ph = plt.fill(pts[:, 0], pts[:, 1], 'r', lw=2)
53+
54+
tellme('Happy? Key click for yes, mouse click for no')
55+
56+
if plt.waitforbuttonpress():
57+
break
58+
59+
# Get rid of fill
60+
for p in ph:
61+
p.remove()
62+
63+
64+
# %%
65+
# Now contour according to distance from triangle
66+
# corners - just an example
67+
68+
# Define a nice function of distance from individual pts
69+
def f(x, y, pts):
70+
z = np.zeros_like(x)
71+
for p in pts:
72+
z = z + 1/(np.sqrt((x - p[0])**2 + (y - p[1])**2))
73+
return 1/z
74+
75+
76+
X, Y = np.meshgrid(np.linspace(-1, 1, 51), np.linspace(-1, 1, 51))
77+
Z = f(X, Y, pts)
78+
79+
CS = plt.contour(X, Y, Z, 20)
80+
81+
tellme('Use mouse to select contour label locations, middle button to finish')
82+
CL = plt.clabel(CS, manual=True)
83+
84+
# %%
85+
# Now do a zoom
86+
87+
tellme('Now do a nested zoom, click to begin')
88+
plt.waitforbuttonpress()
89+
90+
while True:
91+
tellme('Select two corners of zoom, middle mouse button to finish')
92+
pts = plt.ginput(2, timeout=-1)
4593
if len(pts) < 2:
4694
break
4795
(x0, y0), (x1, y1) = pts
4896
xmin, xmax = sorted([x0, x1])
4997
ymin, ymax = sorted([y0, y1])
50-
ax.set(xlim=(xmin, xmax), ylim=(ymin, ymax))
51-
plt.draw()
52-
tellme('Click when ready')
53-
plt.waitforbuttonpress()
98+
plt.xlim(xmin, xmax)
99+
plt.ylim(ymin, ymax)
54100

55-
tellme('All done')
101+
tellme('All Done!')
56102
plt.show()

0 commit comments

Comments
 (0)