繁体   English   中英

在ete2中作为NodeStyle形状的矩形

[英]Rectangle as NodeStyle shape in ete2

我想在ete2中为树状图创建自己的布局。 我有非常具体的需求来逐个节点自定义树节点(即每个节点都有不同的样式等。)

是否可以将节点的形状设置为矩形(我找到了圆形,正方形和球形作为选项)? 我想为每个节点手动设置长度和高度。

另外,您是否对ete2有任何经验。 定制是否有任何限制? 它看起来像是可视化树木的好工具,但是我想创建某种更“特殊”的布局。

提前致谢,

L.

通过NodeStyle仅支持fillRects。 但是,通过在节点的右分支位置添加RectFace ,可以获得相同的效果和更多的控制。 还有许多其他配置可用。 例如:

from ete2 import Tree, RectFace, TreeStyle, AttrFace
tree = Tree()
tree.populate(10)

# Disable auto tip names
ts = TreeStyle()
ts.show_leaf_name = False

for node in tree.traverse():
    # disable default node shapes
    node.img_style["size"] = 0
    # add a custom rect shapes to nodes
    rectF = RectFace(10, 10, "blue", "white")
    rectF.margin_right = 5
    node.add_face(rectF, column=0, position="branch-right")

    # Add tip names in a custom position
    if node.is_leaf():
        nameF = AttrFace("name", fsize=10, fgcolor="slateGrey")
        node.add_face(nameF, column=1, position="branch-right")

tree.show(tree_style=ts)

ETE定制树

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM