Closed MariusCausemann closed 1 year ago
I found a way to get around this problem: Instead of updating the colours directly, one can go via the attribute
of the plot object and get the changing colours in the animation:
import k3d
import numpy as np
from k3d.helpers import map_colors
np.random.seed(2022)
x = np.random.randn(100,3).astype(np.float32)
plt_points = k3d.points(x,
attribute=np.linalg.norm(x,axis=-1),
point_size=0.2)
times = np.linspace(0, 20, 20)
plot = k3d.plot()
plot += plt_points
plt_points.positions = {str(t):x - t/5*x/np.linalg.norm(x,axis=-1)[:,np.newaxis] for t in times}
plt_points.attribute = {str(t): np.linalg.norm(x,axis=-1) for t,x in zip(times, plt_points.positions.values())}
plot.display()
My problem is solved now, so feel free to close the issue.
@MariusCausemann good solution :). Attribute will give you option to interpolate value on colormap space rather on linear rgb. btw you discovered not supported feature in k3d - interpolation of rgb coded variable. It is doable - I will investigate that (to run also your first attempt in k3d)
I also don't like performance of animation here.
Done :). Thanks for good feedback. Thanks to you we will have good colorhex interpolation + speed up of animation.
Nice! Thanks for fixing this and implementing the colorhex interpolation!
@MariusCausemann thanks for finding that!
Description
I want to create time-dependent figures with the colour of the points changing over time. However, the colour is only correctly displayed at the time instances that are provided in the dict of colours for each time step. Interpolated colours generated by kd3 for intermediate times are seemingly random, so the time loop shows randomly flickering colours.
What I Did