Labels colors in Bio.Phylo
0
0
Entering edit mode
21 months ago

I am trying to familiarize with Biopython for phylogenetics with the official documentation.

Using the code below, I have plotted a phylogenetic tree.

from io import StringIO
from Bio import Phylo
from Bio.Phylo.Applications import PhymlCommandline
from Bio.Phylo.PAML import codeml
from Bio.Phylo.PhyloXML import Phylogeny
%matplotlib inline

# Load IQtree tree file data:
tree = Phylo.read('example.phy.treefile', "newick")

# Input the tree name:
tree.name = 'Example phylogenetic tree'

# Draw the tree plot:
fig = plt.figure(figsize=(16, 18), dpi=100)
ax = fig.add_subplot(1, 1, 1)
Phylo.draw(tree, axes=ax)

Unfortunately the confidence levels on the axes are difficult to read, and I wish to change their colour to blue. I have tried the different codes below to change the colour, but none is working. Would anyone know the way to do it?

tree.branch_labels.color="blue"
tree.Clade.confidence.color = 'blue'
tree.Clade.color = 'blue'
Clade.confidence.color = 'blue'

Example file: https://drive.google.com/file/d/1t9kbd2ySn_B2rkgf5aJ-dgUBcCTFJ3PN/view?usp=sharing

Tree plot: https://drive.google.com/file/d/1S774FWaSzIIRU-EPdt2MAJTWIrQEMiOe/view?usp=sharing

Bio.Phylo Python BioPython • 1.2k views
ADD COMMENT
1
Entering edit mode

You can try plt.rcParams["text.color"] = 'blue'.

# Draw the tree plot
plt.rcParams["text.color"] = 'blue'
fig = plt.figure(figsize=(16, 18), dpi=100)
ax = fig.add_subplot(1, 1, 1)
Phylo.draw(tree, axes=ax)

Crosspost: https://stackoverflow.com/q/74069786/3548799

ADD REPLY

Login before adding your answer.

Traffic: 2773 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6