k3d.factory.lines(vertices, indices, indices_type='triangle', color=255, colors=[], attribute=[], color_map=None, color_range=[], width=0.01, shader='thick', radial_segments=8, opacity=1.0, name=None, group=None, custom_data=None, compression_level=0, **kwargs)[source]#

Create a Line drawable for plotting segments and polylines.

  • verticesarray_like. Array with (x, y, z) coordinates of segment endpoints.

  • indicesarray_like. Array of vertex indices: int pair of indices from vertices array.

  • indices_type

    str. Interpretation of indices array Legal values are:


    indices contains pair of values,


    indices contains triple of values

  • colorint. Packed RGB color of the lines (0xff0000 is red, 0xff is blue) when colors is empty.

  • colorsarray_like. Array of int: packed RGB colors (0xff0000 is red, 0xff is blue) when attribute, color_map and color_range are empty.

  • attributearray_like. Array of float attribute for the color mapping, coresponding to each vertex.

  • color_maplist. 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.

  • color_rangelist. A pair [min_value, max_value], which determines the levels of color attribute mapped to 0 and 1 in the color map respectively.

  • shader

    str. Display style (name of the shader used) of the lines. Legal values are:


    simple lines,


    thick lines,


    high precision triangle mesh of segments (high quality and GPU load).

  • radial_segments – ‘int’. Number of segmented faces around the circumference of the tube

  • widthfloat. Thickness of the lines.

  • opacityfloat. Opacity of line.

  • namestring. A name of a object

  • groupstring. A name of a group

  • custom_datadict A object with custom data attached to object.




# VTP model from

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,
              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