Skip to content

Commit 9a6e14c

Browse files
committed
Make the default margins accessible as attributes
Trivial, but helps when e.g. calculating plot positions
1 parent 1a1e75e commit 9a6e14c

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

python/tskit/drawing.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,12 @@ 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 # will also have line_height appended if there is a title
1620+
margin_bottom = (
1621+
15 # lowest plot points will be line_height above this bottom margin
1622+
)
16171623

16181624
def __init__(
16191625
self,
@@ -1821,10 +1827,10 @@ def __init__(
18211827
add_class(self.mutation_label_attrs[m], "lab")
18221828

18231829
self.set_spacing(
1824-
top=10 if title is None else 10 + self.line_height,
1825-
left=20,
1826-
bottom=15,
1827-
right=20,
1830+
top=self.margin_top + (0 if title is None else self.line_height),
1831+
left=self.margin_left,
1832+
bottom=self.margin_bottom,
1833+
right=self.margin_right,
18281834
)
18291835
if title is not None:
18301836
self.add_text_in_group(

0 commit comments

Comments
 (0)