BetterDocs
Home
Docs

Creation | np.meshgrid()

Method:

np.meshgrid(*xi, copy=True, sparse=False, indexing='xy')

Generates coordinate matrices from coordinate vectors.

Returns:

(np.ndarray1, np.ndarray2 ..., np.ndarrayn)

Parameters:

*xi: array-like-

One or more 1D arrays representing the coordinates.

import numpy as np
x = np.array([1, 2, 3])
y = np.array([4, 5])
a, b = np.meshgrid(x, y)
print(a)
print(b)
'''
Output:
[[1 2 3]
 [1 2 3]]
[[4 4 4]
 [5 5 5]]
'''

copy: (True or False), Optional-

If True (default), return copies of the arrays. If False, return views. Please refer to np.array(copy=)  for a better explnation along with examples.

sparse: (True or False), Optional-

If True, returns a sparse grid (default False).

sparse = False (default) +

sparse = True (default) +

indexing: ('xy' or 'ij') Optional-

Determines the ordering of the indices.

indexing = 'xy' (default) +

indexing = 'ij' +


Logo

BetterDocs

Support

EmailDiscordForms

Documentations

Python

Company

AboutDocs

Policies

Terms of ServicePrivacy Policy