vector_poly_data#
- vector_poly_data(orig, vec)[source]#
Create a pyvista.PolyData object composed of vectors.
- Parameters
- orig
numpy.ndarray
Array of vector origins.
- vec
numpy.ndarray
Array of vectors.
- orig
- Returns
pyvista.PolyData
Mesh containing the
orig
points along with the'vectors'
and'mag'
point arrays representing the vectors and magnitude of the the vectors at each point.
Examples
Create basic vector field. This is a point cloud where each point has a vector and magnitude attached to it.
>>> import pyvista >>> import numpy as np >>> x, y = np.meshgrid(np.linspace(-5,5,10),np.linspace(-5,5,10)) >>> points = np.vstack((x.ravel(), y.ravel(), np.zeros(x.size))).T >>> u = x/np.sqrt(x**2 + y**2) >>> v = y/np.sqrt(x**2 + y**2) >>> vectors = np.vstack((u.ravel()**3, v.ravel()**3, np.zeros(u.size))).T >>> pdata = pyvista.vector_poly_data(points, vectors) >>> pdata.point_data.keys() ['vectors', 'mag']
Convert these to arrows and plot it.
>>> pdata.glyph(orient='vectors', scale='mag').plot()