Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
I want to change the font of each node's text. Currently, I'm doing this:
import ete3
def nodeStyler(node: ete3.TreeNode):
# Set node style
nstyle = ete3.NodeStyle()
nstyle["size"] = 0
node.set_style(nstyle)
# Set style of node's text
s = node.name if node.name else "{}"
F = ete3.TextFace(s, tight_text=True, ftype="CMU Serif")
F.rotation = -90
node.add_face(F, column=0, position="branch-right") # Adds extra text
node.name = "" # Removes the default text ... don't know how else to do it.
# Build tree
t = ete3.Tree("((aabc,aabd,aabef)aab,ab,b);", format=8)
# Style tree
ts = ete3.TreeStyle()
ts.show_leaf_name = True
ts.show_scale = False
ts.rotation = 90
ts.min_leaf_separation = 75
ts.layout_fn = nodeStyler
t.render("test_tree.pdf", tree_style=ts)
However, this results in doubled-up text after rendering:
Zoomed in:
Presumably, this is because there already is text and I'm adding more, but I don't understand how the existing text would have its font changed by me adding new text.
Try it with ts.show_leaf_name = False, this should remove the automatically-added node.name text; I might have misunderstood something but I never use ts.show_leaf_name when names or name properties are edited.
I want to change the font of each node's text. Currently, I'm doing this:
However, this results in doubled-up text after rendering:
Zoomed in:
Presumably, this is because there already is text and I'm adding more, but I don't understand how the existing text would have its font changed by me adding new text.