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()
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()
tg.latexOtherPreambleCommands.append(r"\colorlet{bact3}{bact2!20!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{eury3}{eury2!15!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{euka3}{euka2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{cren3}{cren2!20!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{thau3}{thau2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{aiga3}{aiga2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{kora3}{kora2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{ther3}{ther2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{dpan3}{dpan2!30!white}")

tg.font = 'helvetica'
tg.documentFontSize = 10
tg.dirName = 'Gram'
#tg.pdfViewer = 'ls' #'open'
tg.baseName = treename

tg.leafLabelSize = 'normalsize'
tg.internalNodeLabelSize = 'normalsize'
tg.branchLabelSize = 'small'
tg.tgDefaultLineThickness = 'thick'  # default 'semithick'
tg.setScaleBar(yOffset=-1.0, length=0.2)
t.draw()
tg.bracketsLineUp = False
tg.render()
st = tg.tikzStyleDict['bracket label']
st.textShape = 'itshape'
st.textSize = 'large'

tg.fixTextOverlaps()
tg.epdf()
示例#5
0
tg.latexOtherPreambleCommands.append(r"\colorlet{bact3}{bact2!20!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{eury3}{eury2!15!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{euka3}{euka2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{cren3}{cren2!20!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{thau3}{thau2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{aiga3}{aiga2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{kora3}{kora2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{ther3}{ther2!30!white}")
tg.latexOtherPreambleCommands.append(r"\colorlet{dpan3}{dpan2!30!white}")
    
tg.font = 'helvetica'
tg.documentFontSize=10
tg.dirName = 'Gram'
#tg.pdfViewer = 'ls' #'open'
tg.baseName = treename

tg.leafLabelSize = 'normalsize'
tg.internalNodeLabelSize = 'normalsize'
tg.branchLabelSize = 'small'
tg.tgDefaultLineThickness = 'thick' # default 'semithick'
tg.setScaleBar(yOffset = -1.0,length=0.2)
t.draw()
tg.bracketsLineUp = False
tg.render()
st = tg.tikzStyleDict['bracket label']
st.textShape = 'itshape'
st.textSize = 'large'

tg.fixTextOverlaps()   
tg.epdf()