Skip to content

flint: Added plot3d

Valentin Valls requested to merge plot3d into master

This PR added a plot3D to Flint and BLISS

  • Supports scatter 3D
  • Supports meshes

The API is based on descriptive API from the plot1d.

  • The items have to be described with "channel" names
  • Then this channels have to be updated with set_data

image

import numpy
import gevent

f = flint()
p = f.get_plot("plot3d", unique_name="LargeCollider")
p.add_mesh_item("vertices", "faces", color=[0.5, 0.5, 0.5, 0.8])
p.add_scatter_item("x", "y", "z", "v", legend="radar", symbol="o", lut="Accent", vmin=-1.5, vmax=6.5)

# Display the detector
mesh = numpy.load("/users/valls/Downloads/mesh.npz")
vertices = mesh['vertices']
faces = mesh['faces']
p.set_data(vertices=vertices, faces=faces.astype(numpy.uint16))

# Display the first detection
n = numpy.load("/users/valls/Downloads/data", allow_pickle=True)
xyz = numpy.array(n[()]["pts3d"])
value = n[()]["labels"]
x = xyz[:, 0]
y = xyz[:, 1]
z = xyz[:, 2]
p.set_data(x=x, y=y, z=z, v=value)

# auto scale the scene
p.reset_zoom()

# Live refresh
def update():
    while True:
        s = len(x)
        p.set_data(x=x+numpy.random.poisson(30, s),
                   y=y+numpy.random.poisson(30, s),
                   z=z+numpy.random.poisson(30, s), v=value)
        gevent.sleep(1)
gevent.spawn(update)
Edited by Valentin Valls

Merge request reports