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

Skip to content

Commit 0c56410

Browse files
committed
Remove numerix as nx from pylab
svn path=/trunk/matplotlib/; revision=4191
1 parent c187ee2 commit 0c56410

19 files changed

Lines changed: 100 additions & 73 deletions

examples/animation_blit_fltk.py

Lines changed: 4 additions & 4 deletions
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 numpy as nx
6+
import numpy as npy
77
import time
88

99

@@ -29,7 +29,7 @@ def update(self,ptr):
2929
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
3030
self.canvas.restore_region(self.background)
3131
# update the data
32-
line.set_ydata(nx.sin(x+self.cnt/10.0))
32+
line.set_ydata(npy.sin(x+self.cnt/10.0))
3333
# just draw the animated artist
3434
self.ax.draw_artist(line)
3535
# just redraw the axes rectangle
@@ -45,8 +45,8 @@ def update(self,ptr):
4545
p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
4646
p.grid() # to ensure proper background restore
4747
# create the initial line
48-
x = nx.arange(0,2*nx.pi,0.01)
49-
line, = p.plot(x, nx.sin(x), animated=True)
48+
x = npy.arange(0,2*npy.pi,0.01)
49+
line, = p.plot(x, npy.sin(x), animated=True)
5050
p.draw()
5151
anim=animator(ax)
5252

examples/annotation_demo.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@
3232
"""
3333

3434

35-
from pylab import figure, show, nx
35+
from matplotlib.pyplot import figure, show
3636
from matplotlib.patches import Ellipse
37+
import numpy as npy
38+
3739

3840
if 1:
3941
# if only one location is given, the text and xypoint being
4042
# annotated are assumed to be the same
4143
fig = figure()
4244
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5))
4345

44-
t = nx.arange(0.0, 5.0, 0.01)
45-
s = nx.cos(2*nx.pi*t)
46+
t = npy.arange(0.0, 5.0, 0.01)
47+
s = npy.cos(2*npy.pi*t)
4648
line, = ax.plot(t, s, lw=3, color='purple')
4749

4850
ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction',
@@ -85,8 +87,8 @@
8587
# respected
8688
fig = figure()
8789
ax = fig.add_subplot(111, polar=True)
88-
r = nx.arange(0,1,0.001)
89-
theta = 2*2*nx.pi*r
90+
r = npy.arange(0,1,0.001)
91+
theta = 2*2*npy.pi*r
9092
line, = ax.plot(theta, r, color='#ee8d18', lw=3)
9193

9294
ind = 800
@@ -115,8 +117,8 @@
115117
ax.add_artist(el)
116118
el.set_clip_box(ax.bbox)
117119
ax.annotate('the top',
118-
xy=(nx.pi/2., 10.), # theta, radius
119-
xytext=(nx.pi/3, 20.), # theta, radius
120+
xy=(npy.pi/2., 10.), # theta, radius
121+
xytext=(npy.pi/3, 20.), # theta, radius
120122
xycoords='polar',
121123
textcoords='polar',
122124
arrowprops=dict(facecolor='black', shrink=0.05),

examples/barcode_demo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
from pylab import figure, show, cm, nx
1+
from matplotlib.pyplot import figure, show, cm
2+
from numpy import where
3+
from numpy.random import rand
24

35
# the bar
4-
x = nx.where(nx.mlab.rand(500)>0.7, 1.0, 0.0)
6+
x = where(rand(500)>0.7, 1.0, 0.0)
57

68
axprops = dict(xticks=[], yticks=[])
79
barprops = dict(aspect='auto', cmap=cm.binary, interpolation='nearest')
810

911
fig = figure()
1012

11-
# a vertical barcode
13+
# a vertical barcode -- this is broken at present
1214
x.shape = len(x), 1
1315
ax = fig.add_axes([0.1, 0.3, 0.1, 0.6], **axprops)
1416
ax.imshow(x, **barprops)

examples/broken_barh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
Make a "broken" horizontal bar plot, ie one with gaps
44
"""
5-
from pylab import figure, show, nx
5+
from matplotlib.pyplot import figure, show
66

77
fig = figure()
88
ax = fig.add_subplot(111)

examples/clippath_test.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from pylab import figure, show, nx
1+
from matplotlib.pyplot import figure, show
22
import matplotlib.transforms as transforms
33
from matplotlib.patches import RegularPolygon
44
import matplotlib.agg as agg
5-
5+
from numpy import arange, sin, pi
6+
from numpy.random import rand
67

78
class ClipWindow:
89
def __init__(self, ax, line):
@@ -58,9 +59,9 @@ def _clip(self):
5859

5960
fig = figure(figsize=(8,8))
6061
ax = fig.add_subplot(111)
61-
t = nx.arange(0.0, 4.0, 0.01)
62-
s = 2*nx.sin(2*nx.pi*8*t)
62+
t = arange(0.0, 4.0, 0.01)
63+
s = 2*sin(2*pi*8*t)
6364

64-
line, = ax.plot(t, 2*(nx.mlab.rand(len(t))-0.5), 'b-')
65+
line, = ax.plot(t, 2*(rand(len(t))-0.5), 'b-')
6566
clipwin = ClipWindow(ax, line)
6667
show()

examples/custom_figure_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
You can pass a custom Figure constructor to figure if youy want to derive from the default Figure. This simple example creates a figure with a figure title
33
"""
4-
from pylab import figure, show, nx
4+
from matplotlib.pyplot import figure, show
55
from matplotlib.figure import Figure
66

77
class MyFigure(Figure):

examples/date_demo_convert.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/usr/bin/env python
22

33
import datetime
4-
from pylab import figure, show, nx
4+
from matplotlib.pyplot import figure, show
55
from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange
6-
6+
from numpy import arange
77

88
date1 = datetime.datetime( 2000, 3, 2)
99
date2 = datetime.datetime( 2000, 3, 6)
1010
delta = datetime.timedelta(hours=6)
1111
dates = drange(date1, date2, delta)
1212

13-
y = nx.arange( len(dates)*1.0)
13+
y = arange( len(dates)*1.0)
1414

1515
fig = figure()
1616
ax = fig.add_subplot(111)
@@ -25,7 +25,7 @@
2525
# tick, not the base multiple
2626

2727
ax.xaxis.set_major_locator( DayLocator() )
28-
ax.xaxis.set_minor_locator( HourLocator(nx.arange(0,25,6)) )
28+
ax.xaxis.set_minor_locator( HourLocator(arange(0,25,6)) )
2929
ax.xaxis.set_major_formatter( DateFormatter('%Y-%m-%d') )
3030

3131
ax.fmt_xdata = DateFormatter('%Y-%m-%d %H:%M:%S')

examples/dynamic_collection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import random
22
from matplotlib.collections import RegularPolyCollection
33
import matplotlib.cm as cm
4-
from pylab import figure, show, nx
4+
from matplotlib.pyplot import figure, show
5+
from numpy.random import rand
56

67
fig = figure()
78
ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False)
@@ -29,8 +30,8 @@ def onpress(event):
2930
press 'a' to add a random point from the collection, 'd' to delete one
3031
"""
3132
if event.key=='a':
32-
x,y = nx.mlab.rand(2)
33-
color = cm.jet(nx.mlab.rand())
33+
x,y = rand(2)
34+
color = cm.jet(rand())
3435
offsets.append((x,y))
3536
facecolors.append(color)
3637
fig.canvas.draw()

examples/fill_demo2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from pylab import figure, nx, show
1+
from matplotlib.pyplot import figure, show
2+
from numpy import arange, sin, pi
3+
24
fig = figure()
35
ax = fig.add_subplot(111)
4-
t = nx.arange(0.0,3.01,0.01)
5-
s = nx.sin(2*nx.pi*t)
6-
c = nx.sin(4*nx.pi*t)
6+
t = arange(0.0,3.01,0.01)
7+
s = sin(2*pi*t)
8+
c = sin(4*pi*t)
79
ax.fill(t, s, 'b', t, c, 'g', alpha=0.2)
810
show()

examples/gradient_bar.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from pylab import figure, show, nx, cm
1+
from matplotlib.pyplot import figure, show, cm
2+
from numpy import arange
3+
from numpy.random import rand
24

35
def gbar(ax, x, y, width=0.5, bottom=0):
46
X = [[.6, .6],[.7,.7]]
@@ -19,8 +21,8 @@ def gbar(ax, x, y, width=0.5, bottom=0):
1921
extent=(xmin, xmax, ymin, ymax), alpha=1)
2022

2123
N = 10
22-
x = nx.arange(N)+0.25
23-
y = nx.mlab.rand(N)
24+
x = arange(N)+0.25
25+
y = rand(N)
2426
gbar(ax, x, y, width=0.7)
2527
ax.set_aspect('normal')
2628
show()

0 commit comments

Comments
 (0)