Integration with pythreejs

ipyvolume uses parts of pythreejs, giving a lot of flexibility to tweak the visualizations or behaviour. ## Materials The Scatter object has a material and line_material object, which both are a ShaderMaterial pythreejs object:

import ipywidgets as widgets
import numpy as np
import ipyvolume as ipv
# a scatter plot
x, y, z = np.random.normal(size=(3, 100))
fig = ipv.figure()
scatter = ipv.scatter(x, y, z, marker='box')
scatter.connected = True  # draw connecting lines

Using scatter.material we can tweak the material setting:

scatter.material.visible = False

Or even connect a toggle button to a line_material property.

toggle_lines = widgets.ToggleButton(description="Show lines")
widgets.jslink((scatter.line_material, 'visible'), (toggle_lines, 'value'))


ipyvolume has builtin controls. For more flexibility, a Controls class from can be contructed.

import pythreejs
import ipyvolume as ipv
import numpy as np
fig = ipv.figure()
scatter = ipv.scatter(x, y, z, marker='box')

control = pythreejs.OrbitControls(
# assigning to fig.controls will overwrite the builtin controls
fig.controls = control
control.autoRotate = True
# the controls does not update itself, but if we toggle this setting, ipyvolume will update the controls
fig.render_continuous = True

/home/docs/checkouts/ UserWarning: Message serialization failed with:
Out of range float values are not JSON compliant
Supporting this message is deprecated in jupyter-client 7, please make sure your message is JSON-compliant
  content = self.pack(content)
control.autoRotate = True
toggle_rotate = widgets.ToggleButton(description="Rotate")
widgets.jslink((control, 'autoRotate'), (toggle_rotate, 'value'))


The camera property of ipyvolume is by default a PerspectiveCamera, but other cameras should also work:

text = widgets.Text()
widgets.jslink((, 'position'), (text, 'value'))