plot_tree#

tangles.util.tree.plot_tree(some_tree_node: TreeNode, ax: Axes | None = None, search_center: bool = True, plot_node: Callable[[TreeNode, Axes], None] = None, edge_color: Callable[[TreeNode, TreeNode], Any] = None, node_size: Tuple[float, float] | dict[TreeNode, tuple] = (0.01, 0.01), ax_projection: str = None, plot_edge_annotation: Callable[[TreeNode, TreeNode, Axes], None] = None, edge_annotation_size: Tuple[float, float] = (0.01, 0.01))#

Plot a tree.

Parameters#

some_tree_nodeTreeNode

A tree node of the tree to plot. Any node of the tree can be used.

axmatplotlib.axes.Axes or None

The axes object where the tree is plotted. If None, the currently active axis of matplotlib is used.

search_centerbool

Whether to search a better center node (currently a node with max degree).

plot_nodePlotNodeFunc

A callback function that actually plots the tree. If None, a small circle is plotted at each node position. See print_node_label() for an example of such a callback function. It must take the parameters node of type TreeNode and ax of type Matplotlib.axes.ax.

node_size2-tuple of float or dict[TreeNode, (float,float)]

The width and height of a node as a fraction of the total size of the figure or a dict that returns the node size for each tree node.

ax_projectionstr

The matplotlib projection type of the axes of the node plots. Defaults to ‘rectilinear’ which fits most plots, so it only needs to be set for uncommon plot types.

plot_edge_annotationPlotEdgeAnnotationFunc

A callback function that plots an edge annotation at each edge. If None, no annotation is plotted.

edge_annotation_size2-tuple of float

The width and height of an edge annotation plot as a fraction of the total size of the figure.