In [ ]:
import k3d
import numpy as np
from ipywidgets import interact, IntSlider

width = height = length = 3

color_map = (0xFF0000, 0x00FF00, 0x0000FF)
voxels = np.ones(width * height * length, dtype=np.uint8).reshape((length, height, width))
obj = k3d.voxels(voxels, color_map)

plot = k3d.plot(voxel_paint_color=2)
plot += obj

@interact(color=IntSlider(value=plot.voxel_paint_color, min=0, max=len(color_map)))
def color(color):
    plot.voxel_paint_color = color

plot.display()
In [ ]:
obj.voxels.flatten()  # initial data

Edit object (add/remove some voxels)

In [ ]:
obj.fetch_data('voxels')  # this is an async operation
In [ ]:
obj.voxels.flatten()  # updated data
In [ ]:
obj.visible = False
In [ ]:
obj.visible = True
In [ ]: