ragraph.plot.components.tree
#
Re-usable hierarchy tree plot component.
This module contains the get_tree
method which produces a
Component
for the hierarchy tree of a vertical
list of leaf nodes up to their roots which are put on their left.
Module Contents#
Classes#
Hierarchy tree plot component of leaf nodes up to their roots. |
Functions#
|
Compute coordinates of tree nodes. |
|
Get tree node trace from positional dictionaries. These are the 'dots'. |
|
Compute the actual tree lines of the tree plot. These form the tree shapes. |
|
Draw a line with a curved 90 degree angle from a parent to a child in the tree. |
- class ragraph.plot.components.tree.Tree(leafs: List[ragraph.node.Node], style: ragraph.plot.generic.Style = Style())#
Bases:
ragraph.plot.generic.Component
Hierarchy tree plot component of leaf nodes up to their roots.
Leaf nodes are plotted as a vertical list with their roots on the left side.
- Parameters:
leafs – List of leaf nodes.
style – Plot style mapping.
- ragraph.plot.components.tree._get_data(leafs: List[ragraph.node.Node], style: ragraph.plot.generic.Style) Tuple[Set[ragraph.node.Node], int, Dict[ragraph.node.Node, float], Dict[ragraph.node.Node, float]] #
Compute coordinates of tree nodes.
- Parameters:
leafs – List of leaf nodes.
style – Plot style mapping.
- Returns:
Processed ancestor nodes. Tree depth. Dictionary of node to x position of tree nodes. Dictionary of node to y position of tree nodes.
- ragraph.plot.components.tree._get_node_trace(xdict: Dict[ragraph.node.Node, float], ydict: Dict[ragraph.node.Node, float], style: ragraph.plot.generic.Style) plotly.graph_objs.Scatter #
Get tree node trace from positional dictionaries. These are the ‘dots’.
- Parameters:
xdict – Dictionary of node to x position of tree nodes.
ydict – Dictionary of node to y position of tree nodes.
style – Plot style mapping.
- Returns:
Plotly Scatter trace.
- ragraph.plot.components.tree._get_line_shapes(ancestors: Set[ragraph.node.Node], xdict: Dict[ragraph.node.Node, float], ydict: Dict[ragraph.node.Node, float], style: ragraph.plot.generic.Style) List[Dict[str, Any]] #
Compute the actual tree lines of the tree plot. These form the tree shapes.
- Parameters:
ancestors – Set of processed ancestor nodes.
xdict – Dictionary of node to x position of tree nodes.
ydict – Dictionary of node to y position of tree nodes.
style – Plot style mapping.
- Returns:
List of SVG shapes.
- ragraph.plot.components.tree._get_parent_child_line(x0: Union[int, float], y0: Union[int, float], x1: Union[int, float], y1: Union[int, float], style: ragraph.plot.generic.Style) List[ragraph.plot.svg.SVG] #
Draw a line with a curved 90 degree angle from a parent to a child in the tree.
- Parameters:
x0 – x starting coordinate of the line.
y0 – y starting coordinate of the line.
x1 – x ending coordinate of the line.
x2 – y ending coordinate of the line.
style – Plot style mapping.
- Returns:
List of SVG shape mappings of the different line sections.