本文整理汇总了Python中ete2.TreeStyle.orientation方法的典型用法代码示例。如果您正苦于以下问题:Python TreeStyle.orientation方法的具体用法?Python TreeStyle.orientation怎么用?Python TreeStyle.orientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete2.TreeStyle
的用法示例。
在下文中一共展示了TreeStyle.orientation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotTree
# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import orientation [as 别名]
def plotTree(self, tree, out_fn=None, rotation=270, show_leaf_name=False,
show_branch_length=False, circularTree=False, show_division_nodes=True,
distance_between_branches=4, show_border=False, width=None, height=None):
from ete2 import TreeStyle
from PyQt4 import QtSvg, QtCore, QtGui
from ete2.treeview import qt4_render, drawer, main
ts = TreeStyle()
ts.show_scale = False
ts.show_border = show_border
ts.orientation = 1 # 0, tree is drawn from left-to-right. 1, tree is drawn from right-to-left
ts.rotation = rotation
ts.show_leaf_name = show_leaf_name
ts.show_branch_length = show_branch_length
if circularTree:
ts.mode = 'c'
else:
ts.mode = 'r'
ts.branch_vertical_margin = distance_between_branches
def hideInternalNodesLayout(node):
if not node.is_leaf():
node.img_style["size"] = 0
if show_division_nodes is False:
ts.layout_fn = hideInternalNodesLayout
if out_fn is not None:
scene = qt4_render._TreeScene()
img = ts
tree_item, n2i, n2f = qt4_render.render(tree, img)
scene.init_data(tree, img, n2i, n2f)
tree_item.setParentItem(scene.master_item)
scene.master_item.setPos(0,0)
scene.addItem(scene.master_item)
main.save(scene, out_fn, w=width, h=height, dpi=600)
else:
scene, img = drawer.init_scene(tree, None, ts)
tree_item, n2i, n2f = qt4_render.render(tree, img)
scene.init_data(tree, img, n2i, n2f)
tree_item.setParentItem(scene.master_item)
scene.addItem(scene.master_item)
size = tree_item.rect()
w, h = size.width(), size.height()
svg = QtSvg.QSvgGenerator()
svg.setFileName("test.svg")
svg.setSize(QtCore.QSize(w, h))
svg.setViewBox(size)
pp = QtGui.QPainter()
pp.begin(svg)
scene.render(pp, tree_item.rect(), tree_item.rect(), QtCore.Qt.KeepAspectRatio)
示例2: drawTree
# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import orientation [as 别名]
def drawTree(nwfile, outfile):
from ete2 import Tree, TreeStyle, TextFace
ts = TreeStyle()
ts.show_leaf_name = False
ts.layout_fn = my_layout
ts.branch_vertical_margin = 12.75
ts.orientation = 1
titleFace = TextFace("Phylogenetic Tree", fsize=18, fgcolor="white")
titleFace.margin_top = 15
ts.title.add_face(titleFace, column=1)
t = Tree(nwfile)
t.render(outfile, tree_style=ts)