line_segments_from_points#
- line_segments_from_points(points: VectorLike[float] | MatrixLike[float]) PolyData[source]#
Generate non-connected line segments from points.
Assumes points are ordered as line segments and an even number of points.
- Parameters:
- pointsarray_like[
float] Points representing line segments. An even number must be given as every two vertices represent a single line segment. For example, two line segments would be represented as
np.array([[0, 0, 0], [1, 0, 0], [1, 0, 0], [1, 1, 0]]).
- pointsarray_like[
- Returns:
pyvista.PolyDataPolyData with lines and cells.
Examples#
This example plots two line segments at right angles to each other.
>>> import pyvista as pv
>>> import numpy as np
>>> points = np.array([[0, 0, 0], [1, 0, 0], [1, 0, 0], [1, 1, 0]])
>>> lines = pv.line_segments_from_points(points)
>>> lines.plot()
See Plot a 3D Graph Network for more examples using this function.