Skip to content
Browse files

Phylo.draw: take the default line width and font size from pyplot.rcP…

…arams

Suggested by Tanya Golubchik.
  • Loading branch information...
1 parent b38027e commit e25a1b8bde6c9adba7db92bfe13d1bd4320cadcf @etal etal committed
Showing with 8 additions and 6 deletions.
  1. +8 −6 Bio/Phylo/_utils.py
View
14 Bio/Phylo/_utils.py
@@ -329,7 +329,7 @@ def calc_row(clade):
elif not isinstance(axes, plt.matplotlib.axes.Axes):
raise ValueError("Invalid argument for axes: %s" % axes)
- def draw_clade(clade, x_start, color='k', lw=1):
+ def draw_clade(clade, x_start, color, lw):
"""Recursively draw a tree, down from the given clade."""
x_here = x_posns[clade]
y_here = y_posns[clade]
@@ -337,15 +337,16 @@ def draw_clade(clade, x_start, color='k', lw=1):
if hasattr(clade, 'color') and clade.color is not None:
color = clade.color.to_hex()
if hasattr(clade, 'width') and clade.width is not None:
- lw = clade.width
+ lw = clade.width * plt.rcParams['lines.linewidth']
# Draw a horizontal line from start to here
axes.hlines(y_here, x_start, x_here, color=color, lw=lw)
# Add node/taxon labels
label = label_func(clade)
if label not in (None, clade.__class__.__name__):
axes.text(x_here, y_here, ' ' + label,
- fontsize=10, verticalalignment='center')
- # Add confidence
+ fontsize=0.83*plt.rcParams['font.size'], # aesthetics
+ verticalalignment='center')
+ # Add confidence as a label above the branch
if hasattr(clade, 'confidences'):
# phyloXML supports multiple confidences
conf_label = '/'.join(map(str, map(float, clade.confidences)))
@@ -354,7 +355,8 @@ def draw_clade(clade, x_start, color='k', lw=1):
else:
conf_label = None
if conf_label and show_confidence:
- axes.text(x_start, y_here, conf_label, fontsize=9)
+ axes.text(x_start, y_here, conf_label,
+ fontsize=0.75*plt.rcParams['font.size']) # aesthetics
if clade.clades:
# Draw a vertical line connecting all children
y_top = y_posns[clade.clades[0]]
@@ -365,7 +367,7 @@ def draw_clade(clade, x_start, color='k', lw=1):
for child in clade:
draw_clade(child, x_here, color, lw)
- draw_clade(tree.root, 0)
+ draw_clade(tree.root, 0, 'k', plt.rcParams['lines.linewidth'])
if hasattr(tree, 'name') and tree.name:
axes.set_title(tree.name)
axes.set_xlabel('branch length')

0 comments on commit e25a1b8

Please sign in to comment.
Something went wrong with that request. Please try again.