TreeLayout¶
-
class
visualife.diagrams.TreeLayout(id, viewport, max_screen_x, max_screen_y, **kwargs)¶ Bases:
objectBase class for drawing a tree
Parameters: id – ( string) a string that is used to identify graphical elements of this tree.ID of a node will be created as
ID-idxwhereIDis the ID of this layout object andidxis the index of a node :param viewport: (SvgViewport) or its derivative :param max_screen_x: (int) - right screen coordinate :param max_screen_y: (int) - bottom screen coordinate :param kwargs: - see belowKeyword Arguments (**kwargs) (**kwargs):- width (
number) – width of each node in pixels - height (
number) – height of each node in pixels - separation (
number) – minimum separation between nodes in pixels - x_margin (
number) – white space margin for the diagram on both sides along X axis (in viewport units, e.g. pixels) - y_margin (
number) – white space margin for the diagram on both sides along Y axis
Attributes Summary
idReturns ID string that identifies this drawing Methods Summary
draw(root_node)Draws a binary tree given by its root node :param root_node: ( BTreeNode) - root of the treeget_edge_color(node)Returns the color of a line that connects a given node The color is defined by self.edge_colorproperty of this class as follows: -self.edge_coloris callable :self.edge_color(node.id)will be returned -self.edge_coloris a list :self.edge_color[node.id]will be returned -self.edge_coloris astring:self.edge_colorwill be returned :param node: (TreeNode) - a node that defines the line color :return: color (str)set_style(**kwargs)parses parameters to style this tree :param kwargs: see below Attributes Documentation
-
id¶ Returns ID string that identifies this drawing
Methods Documentation
-
draw(root_node: visualife.diagrams.TreeNode.TreeNode)¶ Draws a binary tree given by its root node :param root_node: (
BTreeNode) - root of the tree
-
get_edge_color(node)¶ Returns the color of a line that connects a given node The color is defined by
self.edge_colorproperty of this class as follows:self.edge_coloris callable :self.edge_color(node.id)will be returnedself.edge_coloris a list :self.edge_color[node.id]will be returnedself.edge_coloris astring:self.edge_colorwill be returned
Parameters: node – ( TreeNode) - a node that defines the line colorReturns: color ( str)
-
set_style(**kwargs)¶ parses parameters to style this tree :param kwargs: see below
Keyword Arguments: - leaves_on_axis (
boolean) – - if
True, all leaves (singletons) will be placed on X axis; otherwise they will be plotted on the Y coordinate accordingly to the clustering hierarchy
- leaves_on_axis (
- scale_edges (
boolean) – - if
True, the length of radial edges will be determined proportionally to the distances stored in a given phylogenetic trees
- scale_edges (
- node_shape (
char) – - a single character defining the shape of each mid-node:
tandsdraw triangles and squares respectively; bothoandcdraw circles
- node_shape (
- node_color (
string,list[string]orcallable) – - color of a mid-tree node
- node_color (
- node_size (
float) – - size of a mid-tree node, e.g. circle radius
- node_size (
- node_stroke (
string) – - color of a mid-tree node outline
- node_stroke (
- node_stroke_width (
float) – - width of a mid-tree node outline
- node_stroke_width (
- leaf_shape (
char) – - a single character defining the shape of each leaf node:
tandsdraw triangles and squares respectively; bothoandcdraw circles
- leaf_shape (
- leaf_color (
string,list[string]orcallable) – - color of a leaf node (i.e. representing a specie or a sequence)
- leaf_color (
- leaf_size (
float) – - size of a leaf node, e.g. circle radius
- leaf_size (
- leaf_stroke (
string) – - color of leaf node outline
- leaf_stroke (
- leaf_stroke_width (
float) – - width of leaf node outline
- leaf_stroke_width (
- label_color (
string,list[string]orcallable) – - color of a label string, if drawn
- label_color (
- width (