ivy.layout module¶
layout nodes in 2d space
The function of interest is calc_node_positions (aka nodepos)
- 
ivy.layout.calc_node_positions(node, width, height, lpad=0, rpad=0, tpad=0, bpad=0, scaled=True, smooth=True, n2coords=None)[source]¶
- Calculate where nodes should be positioned in 2d space for drawing a tree - Parameters: - node (Node) – A (root) node
- width (float) – The width of the canvas
- height (float) – The height of the canvas
- rpad, tpad, bpad (lpad,) – Padding on the edges of the canvas. Optional, defaults to 0.
- scaled (bool) – Whether or not the tree is scaled. Optional, defaults to True.
- smooth (bool) – Whether or not to smooth the tree. Optional, defaults to True.
 - Returns: - Mapping of nodes to Coordinates object - Return type: - Notes - Origin is at upper left 
- 
ivy.layout.cartesian(node, xscale=1.0, leafspace=None, scaled=True, n2coords=None, smooth=0, array=<built-in function array>, ones=<function ones>, yunit=None)[source]¶
- RR: What is the difference between this function and calc_node_positions?
- Is it being used anywhere? -CZ
 
- 
ivy.layout.depth_length_preorder_traversal(node, n2coords=None, isroot=False)[source]¶
- Calculate node depth (root = depth 0) and length to root - Parameters: - node (Node) – A node object - Returns: - Mapping of nodes to coordinate objects. Coordinate
- objects have attributes “depth” and “length_to_root”
 - Return type: - dict 
- 
ivy.layout.nodepos(node, width, height, lpad=0, rpad=0, tpad=0, bpad=0, scaled=True, smooth=True, n2coords=None)¶
- Calculate where nodes should be positioned in 2d space for drawing a tree - Parameters: - node (Node) – A (root) node
- width (float) – The width of the canvas
- height (float) – The height of the canvas
- rpad, tpad, bpad (lpad,) – Padding on the edges of the canvas. Optional, defaults to 0.
- scaled (bool) – Whether or not the tree is scaled. Optional, defaults to True.
- smooth (bool) – Whether or not to smooth the tree. Optional, defaults to True.
 - Returns: - Mapping of nodes to Coordinates object - Return type: - Notes - Origin is at upper left