Skip to content

Commit

Permalink
Phylo.draw: make x-margins more robust/reliable
Browse files Browse the repository at this point in the history
Take xmax from the calculated taxon positions, rather than matplotlib's first
guess at the x-axis limits; base the margin calculations on that value, so that
taxon labels are less likely to overflow the plot.
  • Loading branch information
etal committed Jun 24, 2012
1 parent c97dc2a commit 0769cd8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Bio/Phylo/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,8 @@ def draw_clade(clade, x_start, color, lw):
axes.set_xlabel('branch length')
axes.set_ylabel('taxa')
# Add margins around the tree to prevent overlapping the axes
xmin, xmax = axes.get_xlim()
pad = 0.05 * xmax
axes.set_xlim(-pad, xmax + pad)
xmax = max(x_posns.itervalues())
axes.set_xlim(-0.05 * xmax, 1.25 * xmax)
# Also invert the y-axis (origin at the top)
# Add a small vertical margin, but avoid including 0 and N+1 on the y axis
axes.set_ylim(max(y_posns.itervalues()) + 0.8, 0.2)
Expand Down

0 comments on commit 0769cd8

Please sign in to comment.