5
5
import matplotlib .pyplot as plt
6
6
import matplotlib .tri as tri
7
7
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
10
10
import time
11
11
12
- seed (0 )
12
+ rnd . seed (0 )
13
13
npts = 200
14
14
ngridx = 100
15
15
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 )
18
18
z = x * np .exp (- x ** 2 - y ** 2 )
19
19
20
20
# griddata and contour.
21
21
start = time .clock ()
22
22
plt .subplot (211 )
23
23
xi = np .linspace (- 2.1 , 2.1 , ngridx )
24
24
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' )
26
26
plt .contour (xi , yi , zi , 15 , linewidths = 0.5 , colors = 'k' )
27
27
plt .contourf (xi , yi , zi , 15 , cmap = plt .cm .rainbow ,
28
28
norm = plt .Normalize (vmax = abs (zi ).max (), vmin = - abs (zi ).max ()))
48
48
plt .title ('tricontour (%d points)' % npts )
49
49
print ('tricontour seconds: %f' % (time .clock () - start ))
50
50
51
- plt .show ()
51
+ plt .show ()
0 commit comments