pyvista.Plotter.add_lines

pyvista.Plotter.add_lines#

Plotter.add_lines(
lines,
color='w',
width=5,
label=None,
name=None,
connected=False,
) Actor[source]#

Add lines to the plotting object.

Parameters:
linesnp.ndarray

Points representing line segments. For example, two line segments would be represented as np.array([[0, 1, 0], [1, 0, 0], [1, 1, 0], [2, 0, 0]]).

colorColorLike, default: ‘w’

Either a string, rgb list, or hex color string. For example:

  • color='white'

  • color='w'

  • color=[1.0, 1.0, 1.0]

  • color='#FFFFFF'

widthfloat, default: 5

Thickness of lines.

labelstr, default: None

String label to use when adding a legend to the scene with pyvista.Plotter.add_legend().

namestr, default: None

The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

connectedbool, default: False

Treat lines as points representing a series of connected lines. For example, two connected line segments would be represented as np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0]]). If False, an even number of points must be passed to lines, and the lines need not be connected.

Returns:
pyvista.Actor

Lines actor.

Examples

Plot two lines.

>>> import numpy as np
>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> points = np.array([[0, 1, 0], [1, 0, 0], [1, 1, 0], [2, 0, 0]])
>>> actor = pl.add_lines(points, color='purple', width=3)
>>> pl.camera_position = 'xy'
>>> pl.show()
../../../_images/pyvista-Plotter-add_lines-1_00_00.png

Adding lines with connected=True will add a series of connected line segments.

>>> pl = pv.Plotter()
>>> points = np.array([[0, 1, 0], [1, 0, 0], [1, 1, 0], [2, 0, 0]])
>>> actor = pl.add_lines(points, color='purple', width=3, connected=True)
>>> pl.camera_position = 'xy'
>>> pl.show()
../../../_images/pyvista-Plotter-add_lines-1_01_00.png