numpy.ogrid#
- numpy.ogrid=<numpy.lib._index_tricks_impl.OGridClassobject>#
An instance which returns an open multi-dimensional “meshgrid”.
An instance which returns an open (i.e. not fleshed out) mesh-gridwhen indexed, so that only one dimension of each returned array isgreater than 1. The dimension and number of the output arrays areequal to the number of indexing dimensions. If the step length isnot a complex number, then the stop is not inclusive.
However, if the step length is acomplex number (e.g. 5j), thenthe integer part of its magnitude is interpreted as specifying thenumber of points to create between the start and stop values, wherethe stop valueis inclusive.
- Returns:
- mesh-gridndarray or tuple of ndarrays
If the input is a single slice, returns an array.If the input is multiple slices, returns a tuple of arrays, withonly one dimension not equal to 1.
See also
mgridlike
ogridbut returns dense (or fleshed out) mesh gridsmeshgridreturn coordinate matrices from coordinate vectors
r_array concatenator
- How to create arrays with regularly-spaced values
Examples
>>>fromnumpyimportogrid>>>ogrid[-1:1:5j]array([-1. , -0.5, 0. , 0.5, 1. ])>>>ogrid[0:5,0:5](array([[0], [1], [2], [3], [4]]), array([[0, 1, 2, 3, 4]]))