summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authormelissawm <melissawm@gmail.com>2022-07-15 15:08:32 -0300
committermelissawm <melissawm.github@gmail.com>2022-10-03 21:15:41 -0300
commit5c427d6a597f62352e9baf870e1b2edde58bee45 (patch)
tree6643c88bbeb22f04f866fdb65deda4de00a797f2 /numpy/lib
parent105e2635324718ccc964cfda68a805a0035ffe6d (diff)
downloadnumpy-5c427d6a597f62352e9baf870e1b2edde58bee45.tar.gz
DOC: How to partition domains
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/function_base.py18
-rw-r--r--numpy/lib/index_tricks.py2
2 files changed, 15 insertions, 5 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index a0c94114a..1a840669c 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4956,16 +4956,25 @@ def meshgrid(*xi, copy=True, sparse=False, indexing='xy'):
>>> yv
array([[0., 0., 0.],
[1., 1., 1.]])
- >>> xv, yv = np.meshgrid(x, y, sparse=True) # make sparse output arrays
+
+ The result of `meshgrid` is a coordinate grid:
+
+ >>> import matplotlib.pyplot as plt
+ >>> plt.plot(xv, yv, marker='o', color='k', linestyle='none')
+ >>> plt.show()
+
+ You can create sparse output arrays to save memory and computation time.
+
+ >>> xv, yv = np.meshgrid(x, y, sparse=True)
>>> xv
array([[0. , 0.5, 1. ]])
>>> yv
array([[0.],
[1.]])
- `meshgrid` is very useful to evaluate functions on a grid. If the
- function depends on all coordinates, you can use the parameter
- ``sparse=True`` to save memory and computation time.
+ `meshgrid` is very useful to evaluate functions on a grid. If the
+ function depends on all coordinates, both dense and sparse outputs can be
+ used.
>>> x = np.linspace(-5, 5, 101)
>>> y = np.linspace(-5, 5, 101)
@@ -4982,7 +4991,6 @@ def meshgrid(*xi, copy=True, sparse=False, indexing='xy'):
>>> np.array_equal(zz, zs)
True
- >>> import matplotlib.pyplot as plt
>>> h = plt.contourf(x, y, zs)
>>> plt.axis('scaled')
>>> plt.colorbar()
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 4f414925d..e74553de4 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -232,6 +232,7 @@ class MGridClass(nd_grid):
--------
lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects
ogrid : like mgrid but returns open (not fleshed out) mesh grids
+ meshgrid: return coordinate matrices from coordinate vectors
r_ : array concatenator
Examples
@@ -283,6 +284,7 @@ class OGridClass(nd_grid):
--------
np.lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects
mgrid : like `ogrid` but returns dense (or fleshed out) mesh grids
+ meshgrid: return coordinate matrices from coordinate vectors
r_ : array concatenator
Examples