Leaf names visible despite show_leaf_name=False

23 views
Skip to first unread message
Message has been deleted

Michael Gruenstaeudl

unread,
Nov 26, 2023, 3:16:04 AM11/26/23
to The ETE toolkit
Hello!
The following code is supposed to visualize a minimalistic tree next to a sequence alignment, with the tree leaves displayed as aligned. Especially note the setting ts.show_leaf_name=False
```
from ete3 import PhyloTree, TreeStyle, TextFace
tre = "(A:3,(B:1,C:6));"
aln = """
>A
ATGC
>B
GCAT
>C
AGCT
"""
t = PhyloTree(tre, alignment=aln, alg_format="fasta")
for l in t.iter_leaves():
    l.add_face(TextFace(l.name), 0, position='aligned')
ts = TreeStyle()
ts.show_leaf_name=False
ts.draw_guiding_lines=True
t.show(tree_style=ts)
```
However, the above code displayed both the original leaf names as well as the new (i.e., aligned) ones.
test.jpg
I wish to display only the new (i.e., aligned) leaf names. What part of the above code is incorrect?

Thank you, Michael G.

Michael Gruenstaeudl

unread,
Nov 27, 2023, 6:25:49 PM11/27/23
to The ETE toolkit
A simple, albeit unconventional solution would be to replace the original leaf name with an empty string:

```
for l in t.iter_leaves():
    l.add_face(TextFace(l.name), 0, position='aligned')
    l.name = " "
```
Reply all
Reply to author
Forward
0 new messages