def plot_tree(tree, base_name='tree', dir_name='gram'): read(tree) t = var.trees[-1] for n in t.iterNodes(): if n.isLeaf: try: img = Image.open(get_image_path(n.name)) except IOError as e: print n.name raise e w, h = img.size width, height = None, 6.5 if w > h and (n.name in _wide_images): width, height = 12, None vmargin = 0 lmargin = 11 dimension_name = 'height' dimension = height if height is None: dimension_name = 'width' dimension = width node_name = n.name n.name = r"\hspace{{{0}mm}}\includegraphics[{1}={2}mm,resolution=150]{{{3}}}".format( lmargin, dimension_name, dimension, get_image_path(node_name)) tg = TreeGram(t, yScale=0.8, widthToHeight=0.8) tg.tgDefaultLineThickness = 'very thick' tg.baseName = base_name tg.dirName = dir_name tg.epdf()
def plot_tree(tree, base_name = 'tree', dir_name = 'gram'): read(tree) t = var.trees[-1] for n in t.iterNodes(): if n.isLeaf: try: img = Image.open(get_image_path(n.name)) except IOError as e: print n.name raise e w, h = img.size width, height = None, 6.5 if w > h and (n.name in _wide_images): width, height = 12, None vmargin = 0 lmargin = 11 dimension_name = 'height' dimension = height if height is None: dimension_name = 'width' dimension = width node_name = n.name n.name = r"\hspace{{{0}mm}}\includegraphics[{1}={2}mm,resolution=150]{{{3}}}".format( lmargin, dimension_name, dimension, get_image_path(node_name)) tg = TreeGram(t, yScale=0.8, widthToHeight=0.8) tg.tgDefaultLineThickness = 'very thick' tg.baseName = base_name tg.dirName = dir_name tg.epdf()
g.fill = 'bact3' g = tg.setBracket(17,26, text = "Euryarchaeota", leftNode=16) g.fill = 'eury3' g = tg.setBracket(29,29, text = "Korarchaeota", leftNode=28) g.fill = 'kora3' tg.bracketsLineUp = False #tg.leafLabelSize = 'normalsize' #tg.internalNodeLabelSize = 'normalsize' tg.branchLabelSize = tg.internalNodeLabelSize tg.tgDefaultLineThickness = 'thick' # default 'semithick' #tg.setScaleBar(yOffset = -1.0,length=0.2) tg.setScaleBar(length=0.2) tg.setBrokenBranch(72) n = t.node(1) tg.setBranchLabel(n, "1") # Only one tweak needed, for node 16. # Note that the label is adjusted, not the node. t.node(16).label.xShift = -0.25 tg.render() st = tg.tikzStyleDict['bracket label'] st.textShape = 'itshape' st.textSize = 'large' st = tg.tikzStyleDict['leaf'] st.textShape = 'itshape' tg.epdf()
def plot_tree(tree, base_name="tree", dir_name="gram", show_events=False): read(tree) print var.trees t = var.trees[-1] for n in t.iterNodes(): if n.isLeaf: try: img = Image.open(get_image_path(n.name)) except IOError as e: print n.name raise e w, h = img.size width, height = None, 6.5 if w > h and (n.name in _wide_images): width, height = 8, None vmargin = 0 lmargin = 9 dimension_name = "height" dimension = height if height is None: dimension_name = "width" dimension = width node_name = n.name if node_name in _extinct_images: lmargin += 2 n.name = r"\hspace{{{0}mm}}\includegraphics[{1}={2}mm,resolution=150]{{{3}}}".format( lmargin, dimension_name, dimension, get_image_path(node_name) ) tg = TreeGram(t, yScale=0.65, widthToHeight=1.3) tg.tgDefaultLineThickness = "very thick" tg.baseName = base_name tg.dirName = dir_name l1 = tg.gramLine(6.34, -0.5, 6.34, 11) # l1.lineStyle = 'loosely dashed' # l1.lineThickness = 'ultra thick' l1.lineThickness = 10.0 l2 = tg.gramLine(13.4, -0.5, 13.4, 11) # l2.lineStyle = 'loosely dashed' # l2.lineThickness = 'ultra thick' l2.lineThickness = 10.0 l1.colour = "black!40" l2.colour = "black!40" if not show_events: # print dir(l1) l1.colour = "black!00" l2.colour = "black!00" s = tg.code( r"""\draw [draw=none] (10.97, 9.75) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};""" ) if tree == _sec_tree: s = tg.code( r"""\draw [draw=none] (7.08, 10.4) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};""" ) s = tg.code( r"""\draw [draw=none] (13.17, 7.15) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};""" ) else: s = tg.code( r"""\draw [draw=none] (6.34, 10.4) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};""" ) s = tg.code( r"""\draw [draw=none] (13.4, 7.15) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};""" ) tg.epdf()