def layout_raw(node: TreeNode, tight_mode: bool = True) -> None: """Layout implementation for a tree node Parameters ---------- node : TreeNode the root of the taxonomy tree / sub-tree tight_mode : bool, default=True a mode to print node names more tightly Returns ------- None """ if tight_mode: name_segments = node.name.split(' ') for i, name_segment in enumerate(name_segments): name_face = TextFace(name_segment, tight_text=True) name_face.rotation = 270 node.add_face(name_face, column=i, position="branch-right") else: name_face = TextFace(node.name, tight_text=True) name_face.rotation = 270 node.add_face(name_face, column=0, position="branch-right") nst = NodeStyle() nst["fgcolor"] = "black" nst["size"] = 20 nst["shape"] = "circle" node.set_style(nst)
def layout_lift(node: TreeNode, levels: int = 3) -> None: """Layout implementation for a tree node Parameters ---------- node : TreeNode the root of the taxonomy tree / sub-tree levels : int a number of tree levels to draw Returns ------- None """ name = TextFace(node.name if (int(node.e) < levels or node.Hd == "1") else "", tight_text=True) name.rotation = 270 node.add_face(name, column=0, position="branch-right") nst = NodeStyle() if .2 >= float(node.u) > 0: nst["fgcolor"] = "#90ee90" elif .4 >= float(node.u) > .2: nst["fgcolor"] = "green" elif float(node.u) > .4: nst["fgcolor"] = "#004000" else: nst["fgcolor"] = "red" if node.Hd == "0": nst["size"] = 20 nst["shape"] = "square" else: if node.Ch == "1": nst["size"] = 40 nst["shape"] = "circle" else: nst["size"] = 40 nst["shape"] = "circle" if node.Sq == "1": nst["shape"] = "circle" node.set_style(nst)