/opt/conda/envs/dxtr/lib/python3.12/site-packages/pyvista/plotting/utilities/xvfb.py:48: PyVistaDeprecationWarning: This function is deprecated and will be removed in future version of PyVista. Use vtk-osmesa instead. warnings.warn(
Visualization¶
Visualizing complexes and cochains is fundamental in order to develop and analyse DEC-based simulations. That is why we developped the visu module within Dxtr in order to interact and visualize properly objects of interest.
We chose to rely on two libraries for they both offer a distinct set of useful functionalities:
As a data-analysis driven library, plotly encapsulates a lot of features that enable direct interactions with the data. For instance display of information while overing data. We found such features especially usefull when working on SimplicialComplex or SimplicialManifold instances. It enables us to easily spot a simplex or a group of simplices within a complex and to retrieve their ids. However one shortcoming of plotly is its lack of geometry-dedicated functionalities. For instances, vector field representation is not straight-forward and efficient, making the use of this library ill-suited to display large scale and complex vector fields.
That is where pyvista shines. As a direct spin-off of the VTK library the library handles efficiently complex structures and vector fields. The library also provides advanced features such as multi-panel visualizations, clipping planes and multiple views synchronisation, making it particularly well suited to display Cochains values over large simplical complexes. However, the interactive features present in plotly do not come natively in pyvista.
Let's now showcase some use cases.
Visualizing complexes¶
Let's start by visualizing a simple SimplicialComplex, calling the visualize() method from the dxtr.visu module:
from dxtr.complexes import diamond
from dxtr.visu import visualize
cplx = diamond()
visualize(cplx)
When provided with an instance of SimplicialComplex (or SimplicialManifold), the visualize() function will automatically rely on the plotly library to generate the visualization.
The user can then interact with the generated scene in several ways, for instance:
- Hiding k-simplices of any degrees.
- Retrieving the id of any simplex.
For instance, by overing the various vertices, aka nodes, on the scene, one can retrive the ids of the ones forming the equatorial triangle (i.e. 1,2,3) as well as they positions.
Note: Abstract complexes (i.e. not embedded in any geometry) cannot be visualized:
from dxtr import AbstractSimplicialComplex
asc = AbstractSimplicialComplex(indices=[[1,2,3],[2,4]])
visualize(asc)
dxtr.abstractsimplicialcomplex | INFO: Building a 2-Abstract Simplicial Complex with 1 2-simplices
dxtr.typecheck | WARNING: Only ['Simplex', 'SimplicialComplex', 'Cochain'] accepted as input for visualize.
One can change the size of the nodes, the thickness of the edges or the color of the complex, using respectively the arguments point_size, edge_width and color:
visualize(cplx, size=3, width=3, color='green')