lines#

k3d.factory.lines(vertices: List | ndarray | Tuple, indices: List | ndarray | Tuple, indices_type: str = 'triangle', color: int = 255, colors: List[int] = None, attribute: List | ndarray | Tuple = None, color_map: List[List[float]] | Dict[str, Any] | ndarray | None = None, color_range: List[float] = None, width: float = 0.01, shader: str = 'thick', shininess: float = 50.0, radial_segments: int = 8, opacity: float = 1.0, name: str | None = None, group: str | None = None, custom_data: Dict[str, Any] | None = None, compression_level: int = 0, **kwargs: Any) Lines[source]#

Create a Line drawable for plotting segments and polylines.

Parameters:
  • vertices (array_like) – Array with (x, y, z) coordinates of segment endpoints.

  • indices (array_like) – Array of vertex indices: int pair or triple of indices from vertices array.

  • indices_type ({'segment', 'triangle'}, optional) – Interpretation of indices array. ‘segment’ for pairs, ‘triangle’ for triples. Default is ‘triangle’.

  • color (int, optional) – Packed RGB color of the lines (0xff0000 is red, 0xff is blue) when colors is empty. Default is _default_color.

  • colors (array_like, optional) – Array of int: packed RGB colors (0xff0000 is red, 0xff is blue) when attribute, color_map and color_range are empty. Default is [].

  • attribute (array_like, optional) – Array of float attribute for the color mapping, corresponding to each vertex. Default is [].

  • color_map (list, optional) – A list of float quadruplets (attribute value, R, G, B), sorted by attribute value. The first quadruplet should have value 0.0, the last 1.0; R, G, B are RGB color components in the range 0.0 to 1.0. Default is default_colormap.

  • color_range (list, optional) – A pair [min_value, max_value], which determines the levels of color attribute mapped to 0 and 1 in the color map respectively. Default is [].

  • width (float, optional) – Thickness of the lines. Default is 0.01.

  • shader ({'simple', 'thick', 'mesh'}, optional) – Display style (name of the shader used) of the lines. Default is ‘thick’.

  • shininess (float, optional) – Shininess of object material. Default is 50.0.

  • radial_segments (int, optional) – Number of segmented faces around the circumference of the tube. Default is 8.

  • opacity (float, optional) – Opacity of lines. Default is 1.0.

  • name (str, optional) – A name of the object. Default is None.

  • group (str, optional) – A name of a group. Default is None.

  • custom_data (dict, optional) – An object with custom data attached to object. Default is None.

  • compression_level (int, optional) – Level of compression [-1, 9]. Default is 0.

  • **kwargs – Additional keyword arguments passed to process_transform_arguments.

Returns:

The created Lines drawable object.

Return type:

Lines

Examples#

Basic#

cow.vtp

# VTP model from https://github.com/naucoin/VTKData/blob/master/Data/cow.vtp

import k3d
import numpy as np
import pyvista as pv

data = pv.raed('cow.vtp')

plt_vtk = k3d.vtk_poly_data(data)

lines = k3d.lines(plt_vtk.vertices, plt_vtk.indices,
              shader='mesh', width=0.025,
              color=0xc6884b,
              model_matrix=(1.0, 0.0, 0.0, 0.0,
                            0.0, 0.0, 1.0, 0.0,
                            0.0, 1.0, 0.0, 0.0,
                            0.0, 0.0, 0.0, 1.0))

plot = k3d.plot()
plot += lines
plot.display()