numpy.meshgrid

numpy.meshgrid(x, y)

Return coordinate matrices from two coordinate vectors.

Parameters:

x, y : ndarray

Two 1D arrays representing the x and y coordinates

Returns:

X, Y : ndarray

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 along the first dimension for x, the second for y.

See also

numpy.mgrid
Construct a multi-dimensional “meshgrid” using indexing notation.

Examples

>>> X, Y = numpy.meshgrid([1,2,3], [4,5,6,7])
>>> X
array([[1, 2, 3],
       [1, 2, 3],
       [1, 2, 3],
       [1, 2, 3]])
>>> Y
array([[4, 4, 4],
       [5, 5, 5],
       [6, 6, 6],
       [7, 7, 7]])

Previous topic

numpy.logspace

Next topic

numpy.mgrid

This Page

Quick search