10000 MEP12 on tricontour_vs_griddata.py · Solertis/matplotlib@e0df1dd · GitHub
[go: up one dir, main page]

Skip to content

Commit e0df1dd

Browse files
committed
MEP12 on tricontour_vs_griddata.py
In particular: 1. numpy random functions are imported under `rnd`.
1 parent 0a5314a commit e0df1dd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/pylab_examples/tricontour_vs_griddata.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
import matplotlib.pyplot as plt
66
import matplotlib.tri as tri
77
import numpy as np
8-
from numpy.random import uniform, seed
9-
from matplotlib.mlab import griddata
8+
import numpy.random as rnd
9+
import matplotlib.mlab as mlab
1010
import time
1111

12-
seed(0)
12+
rnd.seed(0)
1313
npts = 200
1414
ngridx = 100
1515
ngridy = 200
16-
x = uniform(-2, 2, npts)
17-
y = uniform(-2, 2, npts)
16+
x = rnd.uniform(-2, 2, npts)
17+
y = rnd.uniform(-2, 2, npts)
1818
z = x*np.exp(-x**2 - y**2)
1919

2020
# griddata and contour.
2121
start = time.clock()
2222
plt.subplot(211)
2323
xi = np.linspace(-2.1, 2.1, ngridx)
2424
yi = np.linspace(-2.1, 2.1, ngridy)
25-
zi = griddata(x, y, z, xi, yi, interp='linear')
25+
zi = mlab.griddata(x, y, z, xi, yi, interp='linear')
2626
plt.contour(xi, yi, zi, 15, linewidths=0.5, colors='k')
2727
plt.contourf(xi, yi, zi, 15, cmap=plt.cm.rainbow,
2828
norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max()))
@@ -48,4 +48,4 @@
4848
plt.title('tricontour (%d points)' % npts)
4949
print('tricontour seconds: %f' % (time.clock() - start))
5050

51-
plt.show()
51+
plt.show()

0 commit comments

Comments
 (0)
0