I am trying to create a family tree. I found an excellent script for achieving this and I understand the Python code that underlies it. The script can be found here: https://github.com/adrienverge/familytreemaker/blob/master/familytreemaker.py
I am hitting a wall at lines 322-342. The script executes successfully, but the output is restricted to two layers. There are four generations in the current tree, so this compression makes the graph impossible decipher.
def output_descending_tree(self, ancestor):
"""Outputs the whole descending family tree from a given ancestor,
in DOT format.
"""
# Find the first households
gen = [ancestor]
print('digraph {\n' + \
'\tnode [shape=box];\n' + \
'\tedge [dir=none];\n')
for p in self.everybody.values():
print('\t' + p.graphviz() + ';')
print('')
while gen:
self.display_generation(gen)
gen = self.next_generation(gen)
print('}')
I think a big part of my problem is there are many nodes since the family is quite large. If I use a subset of my family, the tree renders without any issue.
It looks like I need to add some parameters around lines 331-332, such as:
'\tgraph [nodesep=1, levelsgap=1, ratio=expand, size="10,20"];\n' + \
OR, add additional parameters to ``nodeand/or
edge```.
I found the documentation here: https://www.graphviz.org/doc/info/attrs.html, and I tried a few different parameters without much success. The plot did change size, but the contents became blurry rather than expanding. The parameters I have tried changing are: dimen
, esep
, fontsize
, height
, levels
, and ratio
.
This was a helpful thread: Change Size (Width and Height) of Graph (GraphViz & dot), but my interpreter didn't like the syntax (specifically: nodesep = 1.5;
and ranksep = 1
).
Any advice is greatly appreciated. Thank you!
EDIT: I have attached an anonymized version of my output. This version is less compressed than the version I originally had when I wrote this post. Maybe the changes I have made to the code in the mean time achieved my goals? Not sure which one did it, but thank you all for your feedback.