Question: How Do I Change The Fontsize Usin The Phylo Module From Biopython
0
gravatar for BalderNGS
5.7 years ago by
BalderNGS0
BalderNGS0 wrote:

I'm trying to draw trees using teh Biopython Phylo module.

The trees are OK, but the fonts are huge. How can I make them smaller? I tried something like this but its not working:

tree = Phylo.read(seqtreefile, "newick")
tree.rooted = True
tree = tree.as_phyloxml()
Phylo.draw_graphviz(tree, fontsize='6')
pylab.savefig(os.path.join(outpath,'%s.sequences.png'%model))

(Edited to mark the Python example as code)

phylogeny biopython • 2.5k views
ADD COMMENTlink modified 2.9 years ago by Biostar ♦♦ 20 • written 5.7 years ago by BalderNGS0
4
gravatar for Joseph Hughes
5.7 years ago by
Joseph Hughes2.6k
Scotland, UK
Joseph Hughes2.6k wrote:

If you are trying to do a fancy drawing of a phylogeny, I would highly recommend the python E.T.E. environment for tree exploration and visualisation.

Otherwise, with Bio.Phylo, this worked with me:

Phylo.draw_graphviz(tree,font_size="6")
ADD COMMENTlink modified 5.7 years ago • written 5.7 years ago by Joseph Hughes2.6k
3
gravatar for Peter
5.7 years ago by
Peter5.6k
Scotland, UK
Peter5.6k wrote:

Try this:

from Bio import Phylo
help(Phylo.draw_graphviz)

In particular this bit

... options to try are: ...font_size, font_color, font_weight, font_family* ...

[Edited to stop BioStars turning underscores into italics]

i.e. Try font_size instead of fontsize in your example.

ADD COMMENTlink modified 5.7 years ago • written 5.7 years ago by Peter5.6k

indeed the docs are a bit confusing on the underscores

ADD REPLYlink written 5.7 years ago by BalderNGS0
1
gravatar for Eric T.
5.7 years ago by
Eric T.2.2k
San Francisco, CA
Eric T.2.2k wrote:

The options are a little different for Phylo.draw_graphviz (unrooted tree, meaningless branch lengths) and Phylo.draw (rooted tree, meaningful branch lengths.)

Most of the graphical options in Phylo.draw_graphviz are passed along to networkx.draw.

Phylo.draw uses matplotlib directly, so you can tweak graphical options with the dictionary pyplot.rcParams (try playing with it in ipython), e.g.

>>> from matplotlib import pyplot
>>> pyplot.rcParams['fontsize'] = 'xsmall'
ADD COMMENTlink written 5.7 years ago by Eric T.2.2k
0
gravatar for BalderNGS
5.7 years ago by
BalderNGS0
BalderNGS0 wrote:

Thanks for the answers, Phylo.drawgraphviz(tree,fontsize="6") did it. Thanks Joseph, The ETE look very promising

ADD COMMENTlink written 5.7 years ago by BalderNGS0

This is not an answer, please place your comments with your question above. Thanks!

ADD REPLYlink written 5.7 years ago by Josh Herr5.6k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 660 users visited in the last hour