Skip to content

Commit 008e4a4

Browse files
committed
DOC MEP12 - converted animation to SG/MEP12 compatible
1 parent 774b54d commit 008e4a4

12 files changed

+78
-21
lines changed

examples/animation/basic_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Simple animation examples
44
=========================
55
6-
This example contains two animations. The first is a random walk plot. the
6+
This example contains two animations. The first is a random walk plot. The
77
second is an image animation.
88
"""
99

examples/animation/double_pendulum_animated.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""
2+
===========================
3+
The double pendulum problem
4+
===========================
5+
6+
This animation illustrates the double pendulum problem.
7+
"""
8+
19
# Double pendulum formula translated from the C code at
210
# http://www.physics.usyd.edu.au/~wheat/dpend_html/solve_dpend.c
311

@@ -86,5 +94,5 @@ def animate(i):
8694
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)),
8795
interval=25, blit=True, init_func=init)
8896

89-
#ani.save('double_pendulum.mp4', fps=15)
97+
# ani.save('double_pendulum.mp4', fps=15)
9098
plt.show()

examples/animation/dynamic_image.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""
2+
=================
23
An animated image
4+
=================
5+
6+
This example demonstrates how to animate an image.
37
"""
48
import numpy as np
59
import matplotlib.pyplot as plt
@@ -14,7 +18,7 @@ def f(x, y):
1418
x = np.linspace(0, 2 * np.pi, 120)
1519
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
1620

17-
im = plt.imshow(f(x, y), cmap=plt.get_cmap('viridis'), animated=True)
21+
im = plt.imshow(f(x, y), animated=True)
1822

1923

2024
def updatefig(*args):

examples/animation/dynamic_image2.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"""
2-
An animated image
2+
========================================
3+
An animated image using a list of images
4+
========================================
5+
6+
This examples demonstrates how to animate an image from a list of images (or
7+
Artists).
38
"""
49
import numpy as np
510
import matplotlib.pyplot as plt
@@ -20,13 +25,12 @@ def f(x, y):
2025
for i in range(60):
2126
x += np.pi / 15.
2227
y += np.pi / 20.
23-
im = plt.imshow(f(x, y), cmap='viridis', animated=True)
28+
im = plt.imshow(f(x, y), animated=True)
2429
ims.append([im])
2530

2631
ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,
2732
repeat_delay=1000)
2833

29-
#ani.save('dynamic_images.mp4')
30-
34+
# ani.save('dynamic_images.mp4')
3135

3236
plt.show()

examples/animation/histogram.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
"""
2+
==================
3+
Animated histogram
4+
==================
5+
26
This example shows how to use a path patch to draw a bunch of
3-
rectangles for an animated histogram
7+
rectangles for an animated histogram.
8+
49
"""
510
import numpy as np
611

examples/animation/moviewriter.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
# This example uses a MovieWriter directly to grab individual frames and
2-
# write them to a file. This avoids any event loop integration, but has
3-
# the advantage of working with even the Agg backend. This is not recommended
4-
# for use in an interactive setting.
1+
"""
2+
===========
3+
MovieWriter
4+
===========
5+
6+
This example uses a MovieWriter directly to grab individual frames and write
7+
them to a file. This avoids any event loop integration, but has the advantage
8+
of working with even the Agg backend. This is not recommended for use in an
9+
interactive setting.
10+
11+
"""
512
# -*- noplot -*-
613

714
import numpy as np

examples/animation/rain.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""
2+
===============
23
Rain simulation
4+
===============
35
46
Simulates rain drops on a surface by animating the scale and opacity
57
of 50 scatter points.

examples/animation/random_data.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""
2+
===========
3+
Random data
4+
===========
5+
6+
An animation of random data.
7+
8+
"""
9+
110
import numpy as np
211
import matplotlib.pyplot as plt
312
import matplotlib.animation as animation

examples/animation/simple_3danim.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
============
3+
3D animation
4+
============
5+
26
A simple example of an animated plot... In 3D!
37
"""
48
import numpy as np

examples/animation/strip_chart_demo.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
2-
Emulate an oscilloscope. Requires the animation API introduced in
3-
matplotlib 1.0 SVN.
2+
============
3+
Oscilloscope
4+
============
5+
6+
Emulates an oscilloscope.
47
"""
58
import numpy as np
69
from matplotlib.lines import Line2D

examples/animation/subplots.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
"""
2+
=================
3+
Animated subplots
4+
=================
5+
6+
This example uses subclassing, but there is no reason that the proper function
7+
couldn't be set up and then use FuncAnimation. The code is long, but not
8+
really complex. The length is due solely to the fact that there are a total of
9+
9 lines that need to be changed for the animation as well as 3 subplots that
10+
need initial set up.
11+
12+
"""
13+
114
import numpy as np
215
import matplotlib.pyplot as plt
316
from matplotlib.lines import Line2D
417
import matplotlib.animation as animation
518

619

7-
# This example uses subclassing, but there is no reason that the proper
8-
# function couldn't be set up and then use FuncAnimation. The code is long, but
9-
# not really complex. The length is due solely to the fact that there are a
10-
# total of 9 lines that need to be changed for the animation as well as 3
11-
# subplots that need initial set up.
1220
class SubplotAnimation(animation.TimedAnimation):
1321
def __init__(self):
1422
fig = plt.figure()
@@ -63,7 +71,6 @@ def __init__(self):
6371
def _draw_frame(self, framedata):
6472
i = framedata
6573
head = i - 1
66-
head_len = 10
6774
head_slice = (self.t > self.t[i] - 1.0) & (self.t < self.t[i])
6875

6976
self.line1.set_data(self.x[:i], self.y[:i])
@@ -93,5 +100,5 @@ def _init_draw(self):
93100
l.set_data([], [])
94101

95102
ani = SubplotAnimation()
96-
#ani.save('test_sub.mp4')
103+
# ani.save('test_sub.mp4')
97104
plt.show()

examples/animation/unchained.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
========================
3+
MATPLOTLIB **UNCHAINED**
4+
========================
5+
26
Comparative path demonstration of frequency from a fake signal of a pulsar.
37
(mostly known because of the cover for Joy Division's Unknown Pleasures)
48

0 commit comments

Comments
 (0)