diff --git a/crystal_toolkit/renderables/moleculegraph.py b/crystal_toolkit/renderables/moleculegraph.py index 4704b8f6..71b389df 100644 --- a/crystal_toolkit/renderables/moleculegraph.py +++ b/crystal_toolkit/renderables/moleculegraph.py @@ -62,6 +62,8 @@ def get_molecule_graph_scene( show_bond_length=show_bond_length, visualize_bond_orders=visualize_bond_orders, draw_polyhedra=draw_polyhedra, + edge_weight_name=vis_mol_graph.edge_weight_name, + edge_weight_unit=vis_mol_graph.edge_weight_unit, ) for scene in site_scene.contents: primitives[scene.name] += scene.contents diff --git a/crystal_toolkit/renderables/site.py b/crystal_toolkit/renderables/site.py index ac9579e9..a2e4ee62 100644 --- a/crystal_toolkit/renderables/site.py +++ b/crystal_toolkit/renderables/site.py @@ -49,6 +49,8 @@ def get_site_scene( legend: Legend | None = None, retain_atom_idx: bool = False, total_repeat_cell_cnt: int = 1, + edge_weight_name: str = "bond order", + edge_weight_unit: str = "", ) -> Scene: """Get a Scene object for a Site. @@ -74,6 +76,8 @@ def get_site_scene( legend (Legend | None, optional): Defaults to None. retain_atom_idx (bool, optional): Defaults to False. total_repeat_cell_cnt (int, optional): Defaults to 1. + edge_weight_name (str, optional): Defaults to "bond order". + edge_weight_unit (str, optional): Defaults to "". Returns: Scene: The scene object containing atoms, bonds, polyhedra, magmoms. @@ -192,7 +196,11 @@ def get_site_scene( for idx, connected_site in enumerate(connected_sites): if show_bond_order and connected_site.weight is not None: - name_cyl = f"bond order:{connected_site.weight:.2f}" + if edge_weight_name is None: + edge_weight_name = "bond order" + name_cyl = f"{edge_weight_name}:{connected_site.weight:.2f}" + if edge_weight_unit: + name_cyl += f" ({edge_weight_unit})" if show_bond_length and connected_site.dist is not None: name_cyl += f"\nbond length:{connected_site.dist:.3f}"