Skip to content

Commit accc1de

Browse files
hyanwongbenjeffery
authored andcommitted
Make the default margins accessible as attributes
Trivial, but helps when e.g. calculating plot positions
1 parent 1a1e75e commit accc1de

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

python/tskit/drawing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,10 @@ class SvgTree(SvgAxisPlot):
16141614
PolytomyLine = collections.namedtuple(
16151615
"PolytomyLine", "num_branches, num_samples, line_pos"
16161616
)
1617+
margin_left = 20
1618+
margin_right = 20
1619+
margin_top = 10 # oldest point is line_height below or 2*line_height if title given
1620+
margin_bottom = 15 # youngest plot points are line_height above this bottom margin
16171621

16181622
def __init__(
16191623
self,
@@ -1821,10 +1825,10 @@ def __init__(
18211825
add_class(self.mutation_label_attrs[m], "lab")
18221826

18231827
self.set_spacing(
1824-
top=10 if title is None else 10 + self.line_height,
1825-
left=20,
1826-
bottom=15,
1827-
right=20,
1828+
top=self.margin_top + (0 if title is None else self.line_height),
1829+
left=self.margin_left,
1830+
bottom=self.margin_bottom,
1831+
right=self.margin_right,
18281832
)
18291833
if title is not None:
18301834
self.add_text_in_group(

0 commit comments

Comments
 (0)