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

Skip to content

Commit 2313d18

Browse files
author
pkienzle
committed
Convert to numpy
svn path=/trunk/matplotlib/; revision=3793
1 parent 756ba67 commit 2313d18

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

examples/quadmesh_demo.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44
with some restrictions.
55
"""
66

7-
from matplotlib.mlab import linspace, meshgrid
8-
import matplotlib.numerix as nx
7+
import numpy as nx
98
from pylab import figure,show
10-
import matplotlib.numerix.ma as ma
119
from matplotlib import cm, colors
1210

1311
n = 56
14-
x = linspace(-1.5,1.5,n)
15-
X,Y = meshgrid(x,x);
12+
x = nx.linspace(-1.5,1.5,n)
13+
X,Y = nx.meshgrid(x,x);
1614
Qx = nx.cos(Y) - nx.cos(X)
1715
Qz = nx.sin(Y) + nx.sin(X)
1816
Qx = (Qx + 1.1)
1917
Z = nx.sqrt(X**2 + Y**2)/5;
20-
Z = (Z - nx.mlab.amin(Z)) / (nx.mlab.amax(Z) - nx.mlab.amin(Z))
18+
Z = (Z - nx.amin(Z)) / (nx.amax(Z) - nx.amin(Z))
2119

2220
# The color array can include masked values:
23-
Zm = ma.masked_where(nx.fabs(Qz) < 0.5*nx.mlab.amax(Qz), Z)
21+
Zm = nx.ma.masked_where(nx.fabs(Qz) < 0.5*nx.amax(Qz), Z)
2422

2523

2624
fig = figure()

examples/simple3d.py

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

3-
import matplotlib
4-
matplotlib.rcParams['numerix'] = 'numpy'
5-
import numpy as np
6-
from numpy import arange, cos, linspace, ones, pi, sin
7-
import matplotlib.numerix as nx
8-
from matplotlib.numerix import outerproduct
3+
from numpy import arange, cos, linspace, ones, pi, sin, outer
94

105
import pylab
116
import matplotlib.axes3d as axes3d
@@ -20,9 +15,9 @@
2015
u = arange(0, 2*pi+(delta*2), delta*2)
2116
v = arange(0, pi+delta, delta)
2217

23-
x = outerproduct(cos(u),sin(v))
24-
y = outerproduct(sin(u),sin(v))
25-
z = outerproduct(ones(u.shape), cos(v))
18+
x = outer(cos(u),sin(v))
19+
y = outer(sin(u),sin(v))
20+
z = outer(ones(u.shape), cos(v))
2621

2722
#ax3d.plot_wireframe(x,y,z)
2823
surf = ax3d.plot_surface(x, y, z)

0 commit comments

Comments
 (0)