[SciPy-user] meshgrid
Nils Wagner
nwagner at iam.uni-stuttgart.de
Wed Jul 5 04:31:59 EDT 2006
Bill Baxter wrote:
> Is that new? I don't have a meshgrid function in my scipy 0.4.9.
>
> >>> from scipy import *
> >>> meshgrid
> Traceback (most recent call last):
> File "<input>", line 1, in ?
> NameError: name 'meshgrid' is not defined
> >>> import scipy
> >>> scipy.__version__
> '0.4.9'
>
> mgrid works though:
> numpy.mgrid[-2:2:10j, -1:1:10j].
>
> --bb
>
> On 7/5/06, *Nils Wagner* <nwagner at iam.uni-stuttgart.de
> <mailto:nwagner at iam.uni-stuttgart.de>> wrote:
>
> Hi all,
>
> Is it intended that the shape of the input vectors xcoor, ycoor is
> modified ?
>
> from scipy import *
> xcoor=linspace(-2,2,10)
> ycoor=linspace(-1,1,10)
> print shape(xcoor)
> print shape(ycoor)
> X1,Y1 = meshgrid(xcoor,ycoor)
> print shape(xcoor)
> print shape(ycoor)
>
>
> Output
>
> (10,)
> (10,)
> (1, 10)
> (10, 1)
>
> Nils
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
Sorry it belongs to numpy (see below numpy.lib.function_base) , but here
I get
>>> from scipy import *
>>> meshgrid
<function meshgrid at 0x2aaaace9bc08>
>>> scipy.__version__
'0.5.0.2034'
Help on function meshgrid in module numpy.lib.function_base:
meshgrid(x, y)
For vectors x, y with lengths Nx=len(x) and Ny=len(y), return X, Y
where X and Y are (Ny, Nx) shaped arrays with the elements of x
and y repeated to fill the matrix
EG,
[X, Y] = meshgrid([1,2,3], [4,5,6,7])
X =
1 2 3
1 2 3
1 2 3
1 2 3
Y =
4 4 4
5 5 5
6 6 6
7 7 7
More information about the SciPy-User
mailing list