[SciPy-user] Nit in SciPy tutorial?
Grant Edwards
grante at visi.com
Thu Nov 18 17:34:36 CST 2004
Sorry to be a pest, but I'm confused by something in the
SciPy tutorial. On p23, it says
"[...],the function interpolate.bisplrep is available. This
function takes as required inputs the 1-D arrays x, y, and z
which represent points on the surface z = f (x, y).
In the example code at the bottom of p23:
>>> x,y = mgrid[-1:1:20j,-1:1:20j]
[...]
>>> tck = interpolate.bisplrep(x,y,z,s=0)
According to the text x and y should be 1-D arrays, but I
printed their shapes and x.shape and y.shape are both (20,20).
That's 2-D, right? [It does work.]
A bit of experimenting seems to indicate that x,y,z can either
be 1-D or 2-D, since the following code works as well:
import sys,Gnuplot
from scipy import *
x,y = mgrid[-1:1:20j,-1:1:20j]
x.shape,y.shape = (-1,),(-1,)
z = (x+y)*exp(-6.0*(x*x+y*y))
tck = interpolate.bisplrep(x,y,z,s=0)
xn,yn = mgrid[-1:1:70j,-1:1:70j]
zn = interpolate.bisplev(xn[:,0],yn[0,:],tck)
gp = Gnuplot.Gnuplot()
gp.set_label("xlabel","x")
gp.set_label("ylabel","y")
gp.set_label("zlabel","z")
gp.splot(Gnuplot.Data(x,y,z,with='points'),
Gnuplot.GridData(zn,xn[:,0],yn[0,:],with='lines'))
--
Grant Edwards
grante at visi.com
More information about the SciPy-user
mailing list