In [ ]:
import k3d

vertices = [
    -10, 0, -1,
    10, 0, -1,
    10, 0, 1,
    -10, 0, 1,
]

indices = [
    0, 1, 3,
    1, 2, 3
]

plot = k3d.plot()
plot += k3d.mesh(vertices, indices)
plot.display()
In [ ]:
from ipywidgets import widgets,interact

vertex_attribute = [0, 1, 1, 0]

plot = k3d.plot()
mesh = k3d.mesh(vertices, indices, attribute=vertex_attribute, color_map=k3d.basic_color_maps.CoolWarm, color_range=[0.0, 1.0])
plot += mesh

basic_color_maps = [attr for attr in dir(k3d.basic_color_maps) if not attr.startswith('__')]
paraview_color_maps = [attr for attr in dir(k3d.paraview_color_maps) if not attr.startswith('__')]
matplotlib_color_maps = [attr for attr in dir(k3d.matplotlib_color_maps) if not attr.startswith('__')]

@interact(x=widgets.Dropdown(options=basic_color_maps, value=basic_color_maps[0], description='Basic ColorMap:'))
def g(x):
    mesh.color_map = getattr(k3d.basic_color_maps, x)

@interact(x=widgets.Dropdown(options=paraview_color_maps, value=paraview_color_maps[0], description='ParaView ColorMap:'))
def g(x):
    mesh.color_map = getattr(k3d.paraview_color_maps, x)
    
@interact(x=widgets.Dropdown(options=matplotlib_color_maps, value=matplotlib_color_maps[0], description='MatplolLib ColorMap:'))
def g(x):
    mesh.color_map = getattr(k3d.matplotlib_color_maps, x)

plot.display()
In [ ]:
# show vertex numbers:
import numpy as np
v = np.array(vertices).reshape((len(vertices)//3, 3))
for i, pos in enumerate(v):
    plot += k3d.text(text=str(i), position=pos, color=0, reference_point='cc')
In [ ]: