Skip to content

visualize

visualize(object, library=None, **kwargs)

Draw the provided object with the considered library.

Parameters:

Name Type Description Default
object Simplex, SimplicialComplex, or Cochain

The structure to visualize, should be an instance of Simplex, SimplicialComplex or Cochain.

required
library str

The name of the visualization library to use. If specified, should be either 'plotly' or 'pyvista'. Default is None.

None

Other Parameters:

Name Type Description
degrees int, list of int, or str

The (list of) simplex degree(s) to display. Default is 'all'.

show str

What complex(es) to display. Should be in ['primal', 'dual', 'all']. Default is 'primal'.

highlight dict

Subset of simplices to highlight. If given as dict: - keys : int. simplex degrees. - values : list of int. collection of simplex indices.

Notes

If no library is specified at calling, the choice will be made depending on the type of the first argument: If object is an instance of SimplicialComplex, the plotly-based method will be called. If object is of type Cochain, the pyvista-based method will be called.

Use the plotly-based method for exploration of SimplicialComplex objects for plotly-based methods are interactive; therefore better suited to explore visually the objects.

Use the pyvista-based methods to visualize Cochain objects.

See Also

visualize_with_plotly : The _visualize_with_plotly() function from the visualize_plotly sub-module, for details and specific keyword arguments listing. visualize_with_pyvista : The _visualize_with_pyvista() function from the visualize_pyvista sub-module, for details and specific keyword arguments listing.

Source code in src/dxtr/visu/visualize.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@typecheck([Simplex, SimplicialComplex, Cochain])
def visualize(object: Simplex|SimplicialComplex|Cochain,
              library: Optional[str]=None, **kwargs) -> None:
    """Draw the provided object with the considered library.

    Parameters
    ----------
    object : Simplex, SimplicialComplex, or Cochain
        The structure to visualize, should be an instance of `Simplex`, 
        `SimplicialComplex` or `Cochain`.
    library : str, optional
        The name of the visualization library to use. If specified, should be 
        either 'plotly' or 'pyvista'. Default is None.

    Other Parameters
    ----------------
    degrees : int, list of int, or str, optional
        The (list of) simplex degree(s) to display. Default is 'all'.
    show : str, optional
        What complex(es) to display. Should be in ['primal', 'dual', 'all']. Default is 'primal'.
    highlight : dict, optional
        Subset of simplices to highlight. If given as dict:
            - keys : int. simplex degrees.
            - values : list of int. collection of simplex indices.

    Notes
    -----
    If no library is specified at calling, the choice will be made depending 
    on the type of the first argument: If object is an instance of 
    `SimplicialComplex`, the `plotly`-based method will be called. If object 
    is of type `Cochain`, the `pyvista`-based method will be called.

    Use the `plotly`-based method for exploration of `SimplicialComplex` 
    objects for `plotly`-based methods are interactive; therefore better 
    suited to explore visually the objects.

    Use the `pyvista`-based methods to visualize `Cochain` objects.

    See Also
    --------
    visualize_with_plotly : The `_visualize_with_plotly()` function from the 
        `visualize_plotly` sub-module, for details and specific keyword 
        arguments listing.
    visualize_with_pyvista : The `_visualize_with_pyvista()` function from the 
        `visualize_pyvista` sub-module, for details and specific keyword 
        arguments listing.
    """
    if library is None:
        library = 'pyvista' if isinstance(object, Cochain) else 'plotly'

    if library == 'plotly':
        return visualize_with_plotly(object, **kwargs)

    elif library == 'pyvista':
        return visualize_with_pyvista(object, 
                               fig=kwargs.get('fig', None), 
                               scaling_factor=kwargs.get('scaling_factor', 1), 
                               data_range=kwargs.get('data_range', None),
                               display=kwargs.get('display', True), 
                               layout_parameters=kwargs.get('layout_parameters', {}))