Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text doubling up after add_face #683

Open
GitMew opened this issue Apr 23, 2023 · 1 comment
Open

Text doubling up after add_face #683

GitMew opened this issue Apr 23, 2023 · 1 comment

Comments

@GitMew
Copy link

GitMew commented Apr 23, 2023

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:
image
Zoomed in:
image
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.

@Hemimastix
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants