Cleanup animation examples · matplotlib/matplotlib@8fa927f · GitHub
Skip to content

Commit 8fa927f

Browse files
committed
Cleanup animation examples
I thought that the animation examples section was a bit of an unstructured mess so I tried to reorganize it somewhat. The new list of examples is simple examples =============== animation_demo: plt.pause example simple_anim: FuncAnimation example dynamic_image: FuncAnimation example dynamic_image2: ArtistAnimation example intermediate examples ===================== strip_chart: FuncAnimation example advanced examples ================= histogram: animating a composite artist (namely, a histogram) nice examples ============= bayes: FuncAnimation example double_pendulum: FuncAnimation example, skipped as needing scipy random_walk (renamed from simple_3danim): FuncAnimation example rain: FuncAnimation example unchained: FuncAnimation example movie writing ============= frame_grabbing_sgskip (renamed from moviewriter_sgskip.py) removed ======= animate_decay: overlaps with simple_anim basic_example: equivalent to {simple_anim + dynamic_image2} basic_example_writer_sgskip: split as comments to simple_anim/dynamic_image/dynamic_image2 random_data: overlaps with simple_anim, though using a generator subplots: relies on subclassing private attributes of TimedAnimation, would better be replaced by a FuncAnimation example, overly complex
1 parent a919d79 commit 8fa927f

17 files changed

Lines changed: 92 additions & 386 deletions

doc/api/animation_api.rst

Lines changed: 17 additions & 45 deletions

examples/animation/animate_decay.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

examples/animation/basic_example.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

examples/animation/basic_example_writer_sgskip.py

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
distribution should converge.
1010
"""
1111

12-
# update a distribution based on new data.
12+
import math
13+
1314
import numpy as np
1415
import matplotlib.pyplot as plt
15-
import scipy.stats as ss
1616
from matplotlib.animation import FuncAnimation
1717

1818

19+
def beta_pdf(x, a, b):
20+
return (x**(a-1) * (1-x)**(b-1) * math.gamma(a + b)
21+
/ (math.gamma(a) * math.gamma(b)))
22+
23+
1924
class UpdateDist(object):
2025
def __init__(self, ax, prob=0.5):
2126
self.success = 0
@@ -47,7 +52,7 @@ def __call__(self, i):
4752
# Choose success based on exceed a threshold with a uniform pick
4853
if np.random.rand(1,) < self.prob:
4954
self.success += 1
50-
y = ss.beta.pdf(self.x, self.success + 1, (i - self.success) + 1)
55+
y = beta_pdf(self.x, self.success + 1, (i - self.success) + 1)
5156
self.line.set_data(self.x, y)
5257
return self.line,
5358

examples/animation/double_pendulum_animated_sgskip.py renamed to examples/animation/double_pendulum_sgskip.py

Lines changed: 0 additions & 1 deletion

0 commit comments

Comments
 (0)