[Biopython] Phylo.draw - font size

Eric Talevich eric.talevich at gmail.com
Sat Mar 24 01:21:37 UTC 2012


On Thu, Mar 22, 2012 at 3:55 PM, Eric Talevich <eric.talevich at gmail.com> wrote:
> On Thu, Mar 22, 2012 at 11:20 AM, Tanya Golubchik
> <golubchi at stats.ox.ac.uk> wrote:
>> Hi guys,
>>
>> Does anyone know how to change the font size of the text annotations on
>> the current figure from Phylo.draw (ie the node names)? Changing
>> rcParams['font.size'] changes the axes but not the annotations.
>>
>
> There doesn't seem to be a great way to do this directly, but you can
> scale the entire image on-screen by changing the figure.dpi value. It
> defaults to 80dpi, so this will magnify everything by 50%:
>
>>>> rcParams['figure.dpi'] = 120
>
> Alternatively, you can edit the source of Bio/Phylo/_utils.py at lines
> 347 (taxon labels) and 357 (confidence/support values), or copy the
> entire _utils.draw function into your own code and edit the same lines
> there.
>
> If this feels ridiculous (as it probably does), I can add font_size
> and branch_width_scale keyword arguments in the next release. Would
> that help? Any other options you'd like to see, keeping in mind that
> this function isn't meant to compete with standalone programs like
> Archaeopteryx?

I've fixed this in the trunk:
https://github.com/biopython/biopython/commit/e25a1b8bde6c9adba7db92bfe13d1bd4320cadcf

Now rcParams["font.size"] will scale the fonts as expected (though the
proportions are still hard-coded), and rcParams["lines.linewidth"]
will scale the lines, e.g. if you set the line width to 2 in rcParams,
a branch with width=2 will be displayed with a width of 4 pixels, and
width=0.5 will be displayed with 1 pixel.

Other changes are still in progress.

Cheers,
Eric



More information about the Biopython mailing list