Why using K3D-jupyter?#
K3D-jupyter primarily aims is to be an easy and efficient 3D visualization tool.
To do so, it focuses on straightforward user experience, providing an API similar to the well-known matplotlib, and uses the maximum of accelerated 3D graphics in web browsers.
K3D-jupyter includes many features, making it a lightweight and efficient tool for a
diversity of applications.
Some examples of use cases could be:
Photorealistic volume rendering for data on regular grids.
A prominent example is Computer Tomography data, which can be visualized in real-time with a dataset resolution of \(512^3\). Moreover, it experimentally supports time series, making it possible to display 4D (3D + time) tomography.
High-performance 3D point plot renderer able to display millions of points in web browsers.
For example, point cloud data coming from 3D scanners or for real-time visualization of tracers particles in fluid dynamics.
Display meshes with scalar attributes with dynamic update and animation.
Voxel geometry for both dense and sparse datasets.
For example, in Computer Tomography data segmentation.
Interactivity with Ipywidgets#
K3D-jupyter being an ipywidgets, it natively contains front-end
The ipywidgets architecture allows for communication of these two parts.
K3D-jupyter exposes this communication and allows for easy dataset updates on existing plots.
For example, if
plt_points is an points object,
then a simple assignment on the backend
plt_points.positions = np.array([[1,2,3],[3,2,1]], dtype=np.float32)
will trigger the data transfer of points positions to the front-end and update the plot.
One of the most attractive aspects of this architecture is that the backend process can run on arbitrary remote infrastructure, like in HPC centres where large scale simulations are performed or large datasets are available.
Then is it possible to use the Jupyter Notebook as a remote display for visualizing that data. As the frontend is on the users’ computer, the interactivity of 3D inspection is very good and can achieve fast updates on the whole dataset.
It greatly simplifies K3D-jupyter usage as well as the frontend code since it implements only simple sets of objects. On the other hand, the availability of the back-end does not prohibit from using much more sophisticated visualization pipelines.
An example could be an unstructured volumetric grid with some scalar field. K3D does not support this kind of data, but it can be preprocessed using PyVista to – for example – mesh it with colour coded values. Moreover, if such preprocessing produced a mesh with a small or moderate number of triangles (\(<10^5\)), then it could be interactively explored by linking to other widgets.