MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / anim

Function anim

lib/matplotlib/tests/test_animation.py:21–44  ·  view source on GitHub ↗

Create a simple animation (with options).

(request)

Source from the content-addressed store, hash-verified

19
20@pytest.fixture()
21def anim(request):
22 """Create a simple animation (with options)."""
23 fig, ax = plt.subplots()
24 line, = ax.plot([], [])
25
26 ax.set_xlim(0, 10)
27 ax.set_ylim(-1, 1)
28
29 def init():
30 line.set_data([], [])
31 return line,
32
33 def animate(i):
34 x = np.linspace(0, 10, 100)
35 y = np.sin(x + i)
36 line.set_data(x, y)
37 return line,
38
39 # "klass" can be passed to determine the class returned by the fixture
40 kwargs = dict(getattr(request, 'param', {})) # make a copy
41 klass = kwargs.pop('klass', animation.FuncAnimation)
42 if 'frames' not in kwargs:
43 kwargs['frames'] = 5
44 return klass(fig=fig, func=animate, init_func=init, **kwargs)
45
46
47def test_invalid_writer():

Callers

nothing calls this directly

Calls 5

subplotsMethod · 0.45
plotMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…