Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7a21c5

Browse files
committed
Numpification and cleanup of examples
svn path=/trunk/matplotlib/; revision=3820
1 parent b4e4ad6 commit c7a21c5

49 files changed

Lines changed: 131 additions & 244 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from pylab is nearly unchanged, but there is the
66
new alternative of importing from pyplot to get
77
the state-engine graphics without all the numeric
8-
functions. - EF
8+
functions.
9+
Numpified examples; deleted two that were obsolete;
10+
modified some to use pyplot. - EF
911

1012
2007-09-08 Eliminated gd and paint backends - EF
1113

examples/anim_tk.py

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

examples/animation_blit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import matplotlib
1212
matplotlib.use('GTKAgg')
13-
import matplotlib.numerix as nx
13+
import numpy as npy
1414
import pylab as p
1515

1616

@@ -21,8 +21,8 @@
2121
p.grid() # to ensure proper background restore
2222

2323
# create the initial line
24-
x = nx.arange(0,2*nx.pi,0.01)
25-
line, = p.plot(x, nx.sin(x), animated=True, lw=2)
24+
x = npy.arange(0,2*npy.pi,0.01)
25+
line, = p.plot(x, npy.sin(x), animated=True, lw=2)
2626

2727
# for profiling
2828
tstart = time.time()
@@ -34,7 +34,7 @@ def update_line(*args):
3434
# restore the clean slate background
3535
canvas.restore_region(update_line.background)
3636
# update the data
37-
line.set_ydata(nx.sin(x+update_line.cnt/10.0))
37+
line.set_ydata(npy.sin(x+update_line.cnt/10.0))
3838
# just draw the animated artist
3939
try:
4040
ax.draw_artist(line)

examples/animation_blit_fltk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import matplotlib
44
matplotlib.use('FltkAgg')
55
import pylab as p
6-
import matplotlib.numerix as nx
6+
import numpy as nx
77
import time
88

99

examples/animation_blit_qt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ITERS = 1000
1616

1717
import pylab as p
18-
import matplotlib.numerix as nx
18+
import numpy as npy
1919
import time
2020

2121
class BlitQT(QObject):
@@ -27,8 +27,8 @@ def __init__(self):
2727
self.cnt = 0
2828

2929
# create the initial line
30-
self.x = nx.arange(0,2*nx.pi,0.01)
31-
self.line, = p.plot(self.x, nx.sin(self.x), animated=True, lw=2)
30+
self.x = npy.arange(0,2*npy.pi,0.01)
31+
self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2)
3232

3333
self.background = None
3434

@@ -39,7 +39,7 @@ def timerEvent(self, evt):
3939
# restore the clean slate background
4040
self.canvas.restore_region(self.background)
4141
# update the data
42-
self.line.set_ydata(nx.sin(self.x+self.cnt/10.0))
42+
self.line.set_ydata(npy.sin(self.x+self.cnt/10.0))
4343
# just draw the animated artist
4444
self.ax.draw_artist(self.line)
4545
# just redraw the axes rectangle

examples/animation_blit_qt4.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ITERS = 1000
1111

1212
import pylab as p
13-
import matplotlib.numerix as nx
13+
import numpy as npy
1414
import time
1515

1616
class BlitQT(QtCore.QObject):
@@ -22,8 +22,8 @@ def __init__(self):
2222
self.cnt = 0
2323

2424
# create the initial line
25-
self.x = nx.arange(0,2*nx.pi,0.01)
26-
self.line, = p.plot(self.x, nx.sin(self.x), animated=True, lw=2)
25+
self.x = npy.arange(0,2*npy.pi,0.01)
26+
self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2)
2727

2828
self.background = None
2929

@@ -34,7 +34,7 @@ def timerEvent(self, evt):
3434
# restore the clean slate background
3535
self.canvas.restore_region(self.background)
3636
# update the data
37-
self.line.set_ydata(nx.sin(self.x+self.cnt/10.0))
37+
self.line.set_ydata(npy.sin(self.x+self.cnt/10.0))
3838
# just draw the animated artist
3939
self.ax.draw_artist(self.line)
4040
# just redraw the axes rectangle

examples/animation_blit_tk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
import sys
88
import pylab as p
9-
import matplotlib.numerix as nx
9+
import numpy as npy
1010
import time
1111

1212
ax = p.subplot(111)
1313
canvas = ax.figure.canvas
1414

1515

1616
# create the initial line
17-
x = nx.arange(0,2*nx.pi,0.01)
18-
line, = p.plot(x, nx.sin(x), animated=True, lw=2)
17+
x = npy.arange(0,2*npy.pi,0.01)
18+
line, = p.plot(x, npy.sin(x), animated=True, lw=2)
1919

2020
def run(*args):
2121
background = canvas.copy_from_bbox(ax.bbox)
@@ -26,7 +26,7 @@ def run(*args):
2626
# restore the clean slate background
2727
canvas.restore_region(background)
2828
# update the data
29-
line.set_ydata(nx.sin(x+run.cnt/10.0))
29+
line.set_ydata(npy.sin(x+run.cnt/10.0))
3030
# just draw the animated artist
3131
ax.draw_artist(line)
3232
# just redraw the axes rectangle

examples/animation_blit_wx.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import wx
1313
import sys
1414
import pylab as p
15-
import matplotlib.numerix as nx
15+
import numpy as npy
1616
import time
1717

1818

@@ -30,8 +30,8 @@
3030
p.grid() # to ensure proper background restore
3131

3232
# create the initial line
33-
x = nx.arange(0,2*nx.pi,0.01)
34-
line, = p.plot(x, nx.sin(x), animated=True, lw=2)
33+
x = npy.arange(0,2*npy.pi,0.01)
34+
line, = p.plot(x, npy.sin(x), animated=True, lw=2)
3535

3636
# for profiling
3737
tstart = time.time()
@@ -46,7 +46,7 @@ def update_line(*args):
4646
# restore the clean slate background
4747
canvas.restore_region(update_line.background)
4848
# update the data
49-
line.set_ydata(nx.sin(x+update_line.cnt/10.0))
49+
line.set_ydata(npy.sin(x+update_line.cnt/10.0))
5050
# just draw the animated artist
5151
ax.draw_artist(line)
5252
# just redraw the axes rectangle

examples/backend_driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
'histogram_demo.py',
4343
'image_demo.py',
4444
'image_demo2.py',
45-
'image_demo_na.py',
4645
'image_masked.py',
4746
'image_origin.py',
4847
'invert_axes.py',
@@ -158,7 +157,7 @@ def drive(backend, python='python', switches = []):
158157

159158
if __name__ == '__main__':
160159
times = {}
161-
default_backends = ['Agg', 'PS', 'SVG', 'Template']
160+
default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template']
162161
if sys.platform == 'win32':
163162
python = r'c:\Python24\python.exe'
164163
else:

examples/clippedline.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
from matplotlib.lines import Line2D
7-
import matplotlib.numerix as nx
7+
import numpy as npy
88
from pylab import figure, show
99

1010
class ClippedLine(Line2D):
@@ -19,13 +19,13 @@ def __init__(self, ax, *args, **kwargs):
1919

2020
def set_data(self, *args, **kwargs):
2121
Line2D.set_data(self, *args, **kwargs)
22-
self.xorig = nx.array(self._x)
23-
self.yorig = nx.array(self._y)
22+
self.xorig = npy.array(self._x)
23+
self.yorig = npy.array(self._y)
2424

2525
def draw(self, renderer):
2626
xlim = self.ax.get_xlim()
2727

28-
ind0, ind1 = nx.searchsorted(self.xorig, xlim)
28+
ind0, ind1 = npy.searchsorted(self.xorig, xlim)
2929
self._x = self.xorig[ind0:ind1]
3030
self._y = self.yorig[ind0:ind1]
3131
N = len(self._x)
@@ -43,8 +43,8 @@ def draw(self, renderer):
4343
fig = figure()
4444
ax = fig.add_subplot(111, autoscale_on=False)
4545

46-
t = nx.arange(0.0, 100.0, 0.01)
47-
s = nx.sin(2*nx.pi*t)
46+
t = npy.arange(0.0, 100.0, 0.01)
47+
s = npy.sin(2*npy.pi*t)
4848
line = ClippedLine(ax, t, s, color='g', ls='-', lw=2)
4949
ax.add_line(line)
5050
ax.set_xlim(10,30)

0 commit comments

Comments
 (0)