ipyvolume

Repository: https://github.com/maartenbreddels/ipyvolume

Installation:

conda install -c conda-forge ipyvolume

Volume rendering


In [ ]:
import ipyvolume
import numpy as np

In [ ]:
ds = ipyvolume.datasets.aquariusA2.fetch()
ipyvolume.quickvolshow(ds.data, lighting=True)

Animations

Animations are made in the shaders


In [ ]:
stream = ipyvolume.datasets.animated_stream.fetch()

In [ ]:
fig = ipyvolume.figure()
q = ipyvolume.quiver(*stream.data[:,0:50,:200], color="red", size=7)
ipyvolume.animation_control(q, interval=200)
ipyvolume.show()

In [ ]:
u = np.linspace(-10, 10, 50)
x, y = np.meshgrid(u, u)
r = np.sqrt(x**2+y**2)
x = x.flatten()
y = y.flatten()
r = r.flatten()
time = np.linspace(0, np.pi*2, 50)
z = np.array([(np.cos(r + t) * np.exp(-r/5)) for t in time])
color = np.array([[np.cos(r + t), 1-np.abs(z[i]), 0.1+z[i]*0] for i, t in enumerate(time)])
size = (z+1)
color = np.transpose(color, (0, 2, 1))

In [ ]:
ipyvolume.figure()
s = ipyvolume.scatter(x, z, y, color=color, marker="sphere")
ipyvolume.animation_control(s, interval=200)
ipyvolume.ylim(-3,3)
ipyvolume.show()

In [ ]:
s.geo = "diamond"

In [ ]:
s.size = 5

In [ ]:
s.color = 1 - s.color

Clean


In [ ]:
from ipywidgets import Widget
Widget.close_all()

In [ ]: