Skip to content

Commit ae474ac

Browse files
committed
Update examples to use proper imports.
svn path=/trunk/matplotlib/; revision=8661
1 parent 74ca427 commit ae474ac

File tree

9 files changed

+22
-20
lines changed

9 files changed

+22
-20
lines changed

examples/animation/animate_decay.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
3-
from animation import FuncAnimation
3+
import matplotlib.animation as animation
44

55
def data_gen():
66
t = data_gen.t
@@ -32,5 +32,6 @@ def run(data):
3232

3333
return line,
3434

35-
ani = FuncAnimation(fig, run, data_gen, blit=True, interval=10, repeat=False)
35+
ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=10,
36+
repeat=False)
3637
plt.show()

examples/animation/dynamic_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
import numpy as np
66
import matplotlib.pyplot as plt
7-
from animation import FuncAnimation
7+
import matplotlib.animation as animation
88

99
fig = plt.figure()
1010

@@ -23,5 +23,5 @@ def updatefig(*args):
2323
im.set_array(f(x,y))
2424
return im,
2525

26-
ani = FuncAnimation(fig, updatefig, interval=50, blit=True)
26+
ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True)
2727
plt.show()

examples/animation/dynamic_image2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
import numpy as np
66
import matplotlib.pyplot as plt
7-
from animation import ArtistAnimation
7+
import matplotlib.animation as animation
88

99
fig = plt.figure()
1010

@@ -20,5 +20,6 @@ def f(x, y):
2020
y += np.pi / 20.
2121
ims.append([plt.imshow(f(x, y), cmap=plt.get_cmap('jet'))])
2222

23-
ani = ArtistAnimation(fig, ims, interval=50, blit=True, repeat_delay=1000)
23+
ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,
24+
repeat_delay=1000)
2425
plt.show()

examples/animation/histogram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import matplotlib.pyplot as plt
88
import matplotlib.patches as patches
99
import matplotlib.path as path
10-
from animation import FuncAnimation
10+
import matplotlib.animation as animation
1111

1212
fig = plt.figure()
1313
ax = fig.add_subplot(111)
@@ -58,5 +58,5 @@ def animate(i):
5858
verts[1::5,1] = top
5959
verts[2::5,1] = top
6060

61-
ani = FuncAnimation(fig, animate, 100, repeat=False)
61+
ani = animation.FuncAnimation(fig, animate, 100, repeat=False)
6262
plt.show()

examples/animation/random_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
3-
from animation import FuncAnimation
3+
import matplotlib.animation as animation
44

55
fig = plt.figure()
66
ax = fig.add_subplot(111)
@@ -14,5 +14,5 @@ def update(data):
1414
def data_gen():
1515
while True: yield np.random.rand(10)
1616

17-
ani = FuncAnimation(fig, update, data_gen, interval=100)
17+
ani = animation.FuncAnimation(fig, update, data_gen, interval=100)
1818
plt.show()

examples/animation/simple_3danim.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import numpy as np
55
import matplotlib.pyplot as plt
66
import mpl_toolkits.mplot3d.axes3d as p3
7-
8-
from animation import FuncAnimation
7+
import matplotlib.animation as animation
98

109
def Gen_RandLine(length, dims=2) :
1110
"""
@@ -57,7 +56,7 @@ def update_lines(num, dataLines, lines) :
5756
ax.set_title('3D Test')
5857

5958
# Creating the Animation object
60-
line_ani = FuncAnimation(fig, update_lines, 25, fargs=(data, lines),
59+
line_ani = animation.FuncAnimation(fig, update_lines, 25, fargs=(data, lines),
6160
interval=50, blit=False)
6261

6362
plt.show()

examples/animation/simple_anim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
import numpy as np
55
import matplotlib.pyplot as plt
6-
from animation import FuncAnimation
6+
import matplotlib.animation as animation
77

88
fig = plt.figure()
99
ax = fig.add_subplot(111)
@@ -20,6 +20,6 @@ def init():
2020
line.set_ydata(np.ma.array(x, mask=True))
2121
return line,
2222

23-
ani = FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,
23+
ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,
2424
interval=25, blit=True)
2525
plt.show()

examples/animation/strip_chart_demo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
from matplotlib.lines import Line2D
88
import matplotlib.pyplot as plt
9-
from animation import FuncAnimation
9+
import matplotlib.animation as animation
1010

1111
class Scope:
1212
def __init__(self, ax, maxt=10, dt=0.01):
@@ -45,5 +45,6 @@ def emitter(p=0.01):
4545
fig = plt.figure()
4646
ax = fig.add_subplot(111)
4747
scope = Scope(ax)
48-
ani = FuncAnimation(fig, scope.update, emitter, interval=10, blit=True)
48+
ani = animation.FuncAnimation(fig, scope.update, emitter, interval=10,
49+
blit=True)
4950
plt.show()

examples/animation/subplots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
33
from matplotlib.lines import Line2D
4-
from animation import TimedAnimation
4+
import matplotlib.animation as animation
55

66
# This example uses subclassing, but there is no reason that the proper function
77
# couldn't be set up and then use FuncAnimation. The code is long, but not
88
# really complex. The length is due solely to the fact that there are a total
99
# of 9 lines that need to be changed for the animation as well as 3 subplots
1010
# that need initial set up.
11-
class SubplotAnimation(TimedAnimation):
11+
class SubplotAnimation(animation.TimedAnimation):
1212
def __init__(self):
1313
fig = plt.figure()
1414
ax1 = fig.add_subplot(1, 2, 1)
@@ -54,7 +54,7 @@ def __init__(self):
5454
ax3.set_xlim(-1, 1)
5555
ax3.set_ylim(0, 800)
5656

57-
TimedAnimation.__init__(self, fig, interval=50, blit=True)
57+
animation.TimedAnimation.__init__(self, fig, interval=50, blit=True)
5858

5959
def _draw_frame(self, framedata):
6060
i = framedata

0 commit comments

Comments
 (0)