In [ ]:
import k3d
from ipywidgets import interact, IntSlider

model_matrix = [
    0.9,  0.1, -0.4, 0.0,
    0.0,  0.9,  0.4, 0.0,
    0.4, -0.4,  0.9, 0.0,
    0.0,  0.0,  0.0, 1.0
]

vertices = [
    -10.0, -15.0, 0.0,
    -10.0,   5.0, 0.0,
     10.0,   5.0, 0.0,
    -10.0, -15.0, 0.0,
     10.0, -15.0, 0.0,
    -10.0,   5.0, 0.0,
      0.0,  15.0, 0.0,
     10.0,   5.0, 0.0,
     10.0, -15.0, 0.0
]

line = k3d.line((0, 0, 0, 5, 10, 15), shader="simple")
lines = k3d.line(vertices, model_matrix=model_matrix, color=0xff0000, width=2.5, shader="simple") + line

plot = k3d.plot(antialias=True, camera_auto_fit=True)
plot += lines
plot.display()

# plot.camera_auto_fit = False  # uncomment in order to keep camera at fixed distance on changes
@interact(color=IntSlider(value=line.color, min=0, max=0xffffff))
def update(color):
    line.color = color
In [ ]:
# Not all implementations of WebGL support line width, this may not work:
line.width = 5
In [ ]:
plot -= line
In [ ]:
plot.objects
In [ ]:
plot -= lines
In [ ]: