lines#
- 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.
- Parameters
vertices – array_like. Array with (x, y, z) coordinates of segment endpoints.
indices – array_like. Array of vertex indices: int pair of indices from vertices array.
indices_type –
str. Interpretation of indices array Legal values are:
- segment
indices contains pair of values,
- triangle
indices contains triple of values
color – int. Packed RGB color of the lines (0xff0000 is red, 0xff is blue) when colors is empty.
colors – array_like. Array of int: packed RGB colors (0xff0000 is red, 0xff is blue) when attribute, color_map and color_range are empty.
attribute – array_like. Array of float attribute for the color mapping, coresponding to each vertex.
color_map – list. 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_range – list. 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
simple lines,
- thick
thick lines,
- mesh
high precision triangle mesh of segments (high quality and GPU load).
radial_segments – ‘int’. Number of segmented faces around the circumference of the tube
width – float. Thickness of the lines.
opacity – float. Opacity of line.
name – string. A name of a object
group – string. A name of a group
custom_data – dict A object with custom data attached to object.
Examples#
Basic#
# 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()