add_lines#

PrimePlotter.add_lines(points, connections=None, color='white', width=1.0, **kwargs)#

Add line segments to the scene.

This method provides a backend-agnostic way to add lines to the visualization scene. Lines can connect points sequentially or based on explicit connectivity information.

Parameters:
pointsUnion[List, Any]

Points defining the lines. Can be a list of coordinates or array-like object. Expected format: [[x1, y1, z1], [x2, y2, z2], …] or Nx3 array.

connectionsOptional[Union[List, Any]], default: None

Line connectivity. If None, connects points sequentially (0->1, 1->2, 2->3, …). If provided, should define line segments as pairs of point indices: [[start_idx1, end_idx1], [start_idx2, end_idx2], …] or Mx2 array where M is the number of line segments.

colorstr, default: “white”

Color of the lines. Can be a color name or hex color code.

widthfloat, default: 1.0

Width of the lines in pixels or display units (interpretation depends on backend).

**kwargsdict

Additional backend-specific keyword arguments for advanced customization.

Returns:
:
Any

Backend-specific actor or object representing the added lines. Can be used for further manipulation or removal.

Return type:

Any

Examples

Add a line connecting points sequentially:

>>> from ansys.tools.visualization_interface import Plotter
>>> plotter = Plotter()
>>> points = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
>>> plotter.add_lines(points, color='green', width=2.0)
>>> plotter.show()

Add specific line segments with explicit connectivity:

>>> points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0]]
>>> connections = [[0, 1], [2, 3], [0, 2]]  # Connect specific pairs
>>> plotter.add_lines(points, connections=connections, color='red', width=3.0)
>>> plotter.show()