Tree¶
- detroit.tree() Tree¶
Builds a new tree layout with default settings.
- Returns:
Tree object
- Return type:
- class detroit.hierarchy.tree.Tree¶
Tree layout
- __call__(root: Node) Node¶
Lays out the specified root hierarchy, assigning the following properties on root and its descendants:
node.x- the x-coordinate of the nodenode.y- the y coordinate of the node
The coordinates
xandyrepresent an arbitrary coordinate system; for example, you can treatxas an angle andyas a radius to produce a radial layout. You may want to callroot.sortbefore passing the hierarchy to the tree layout.
- set_separation(separation: Callable[[Node, Node], int]) Tree¶
Sets the
separationaccessor to the specified function and returns this tree layout.
- set_size(size: tuple[float, float]) Tree¶
Sets this tree layout’s size to the specified two-element array of numbers
[width, height]and returns this tree layout. A layout size ofNoneindicates that a node size will be used instead. The coordinatesxandyrepresent an arbitrary coordinate system; for example, to produce a radial layout, a size of[360, radius]corresponds to a breadth of 360° and a depth of radius.- Parameters:
size (tuple[float, float]) – Tree layout’s size
- Returns:
Itself
- Return type:
- set_node_size(node_size: tuple[float, float]) Tree¶
Sets this tree layout’s node size to the specified two-element array of numbers
[width, height]and returns this tree layout. A node size ofNoneindicates that a layout size will be used instead. When a node size is specified, the root node is always positioned at \((0, 0)\).- Parameters:
node_size (tuple[float, float]) – Tree layout’s node size
- Returns:
Itself
- Return type: