How to color leaves on `ete3` Tree? (Python 3)
<p>I just started using <code>ete3</code> and it is awesome. </p>

<p><strong>How can I color the leaves of an <code>ete3</code> Tree object using a color dictionary?</strong> I made <code>"c":None</code> because I don't want the of <code>c</code> to show up. </p>

<p>I want to have better control of the tree render but I can't figure out exactly how to do it. </p>

<p>I saw that there are <a href="http://etetoolkit.org/docs/latest/reference/reference_treeview.html#nodestyle" rel="nofollow"><code>NodeStyle</code> objects</a> but I think this is for the actual nodes.  It looks like this <a href="http://etetoolkit.org/docs/latest/reference/reference_treeview.html#faces" rel="nofollow"><code>TextFace</code> object</a> is what I need but I don't know how to use it.  <a href="http://etetoolkit.org/docs/latest/tutorial/tutorial_drawing.html" rel="nofollow">All the examples</a> are adding labels. </p>

<pre><code># Build Tree
tree = ete3.Tree( "((a,b),c);" )
# Leaf mapping
D_leaf_color = {"a":"r", "b":"g","c":None}
# Set up style for circular tree
ts = ete3.TreeStyle()
ts.mode = "c"
# Draw Tree
tree.render("tree_test.png", dpi=300, w=500, tree_style=ts)
</code></pre>

<p><a href="http://i.stack.imgur.com/NLgyb.png" rel="nofollow"><img src="http://i.stack.imgur.com/NLgyb.png" alt="enter image description here"></a></p>

<p>I looked at this question but it was pretty confusing: 
<a href="http://stackoverflow.com/questions/32389343/how-to-color-tree-nodes-with-fixed-set-of-colors">How to color tree nodes with fixed set of colors?</a></p>

<p>I would do it like this:</p>

<pre><code>from ete3 import Tree, TextFace, TreeStyle

# Build Tree
tree = Tree( "((a,b),c);" )
# Leaf mapping
D_leaf_color = {"a":"red", "b":"green"}
for node in tree.traverse():
    # Hide node circles
    node.img_style['size'] = 0
    if node.is_leaf():
        color = D_leaf_color.get(node.name, None)
        if color:
            name_face = TextFace(node.name, fgcolor=color, fsize=10)
            node.add_face(name_face, column=0, position='branch-right')
# Set up style for circular tree
ts = TreeStyle()
ts.mode = "c"
ts.scale = 10
# Disable the default tip names config
ts.show_leaf_name = False
ts.show_scale = False
# Draw Tree
tree.render("tree_test.png", dpi=300, w=500, tree_style=ts)
</code></pre>

<p><a href="http://i.stack.imgur.com/HKYAQ.png" rel="nofollow"><img src="http://i.stack.imgur.com/HKYAQ.png" alt="enter image description here"></a></p>

python colors tree etetoolkit ete3