There are two ways of changing data in the plot:

  • send new data from backend

  • sent time series in the form of dictionary {t1:data1,t2:data2,...}

import k3d
import numpy as np
x = np.random.randn(100,3).astype(np.float32)
plot = k3d.plot(name='points')
plt_points = k3d.points(positions=x, point_size=0.2, shader='3d')
plot += plt_points

Using backend to send a data at each timestep

The Python backend can update attribute of any plot object in K3D-jupyter.

from time import sleep
for t in range(10):
    plt_points.positions = x - t/10*x/np.linalg.norm(x,axis=-1)[:,np.newaxis]

Sending a dictionary of all timesteps

In this case it is possible to play an animation using only frontend. Time is a string denoting wall time.

plt_points.positions = {str(t):x - t/10*x/np.linalg.norm(x,axis=-1)[:,np.newaxis] for t in range(10)}

The animation can be controlled from GUI or by several attributes:

plot.start_auto_play()  # plot.stop_auto_play()

The number of frames which are played can be inspected or set with plot.fps attribute.


One can programatically change or read the time in the animation using: