draw_graphviz(tree,
label_func=<type 'str'>,
prog=' twopi ' ,
args='
' ,
node_color=' #c0deff ' ,
**kwargs)
| source code
|
Display a tree or subtree as a graph, using the graphviz engine.
Requires NetworkX, matplotlib, Graphviz and either PyGraphviz or
pydot.
Example:
>>> import pylab
>>> from Bio import Phylo
>>> tree = Phylo.read('ex/apaf.xml', 'phyloxml')
>>> Phylo.draw_graphviz(tree)
>>> pylab.show()
>>> pylab.savefig('apaf.png')
The third and fourth parameters apply to Graphviz, and the remaining
arbitrary keyword arguments are passed directly to networkx.draw(), which
in turn mostly wraps matplotlib/pylab. See the documentation for
Graphviz and networkx for detailed explanations.
The NetworkX/matplotlib parameters are described in the docstrings for
networkx.draw() and pylab.scatter(), but the most reasonable options to
try are: alpha, node_color, node_size, node_shape, edge_color, style,
font_size, font_color, font_weight, font_family
- Parameters:
label_func - A function to extract a label from a node. By default this is
str(), but you can use a different function to select another
string associated with each node. If this function returns None
for a node, no label will be shown for that node.
The label will also be silently skipped if the throws an
exception related to ordinary attribute access (LookupError,
AttributeError, ValueError); all other exception types will still
be raised. This means you can use a lambda expression that simply
attempts to look up the desired value without checking if the
intermediate attributes are available:
>>> Phylo.draw_graphviz(tree, lambda n: n.taxonomies[0].code)
prog - The Graphviz program to use when rendering the graph. 'twopi'
behaves the best for large graphs, reliably avoiding crossing
edges, but for moderate graphs 'neato' looks a bit nicer. For
small directed graphs, 'dot' may produce the most normal-looking
phylogram, but will cross and distort edges in larger graphs.
(The programs 'circo' and 'fdp' are not recommended.)
args - String of options passed to the external graphviz program.
Normally not needed, but offered here for completeness.
|