1

png image of output here

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/oredge```.

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.

albert
  • 8,285
  • 3
  • 19
  • 32
barleyguy
  • 36
  • 5
  • You could try a larger monitor, or a PDF viewer that allows panning like okular, or a printer/plotter that can do larger pages of paper. You could also try some graphviz commands other than dot - they attempt to deal with large numbers of nodes differently, IE https://manpages.debian.org/jessie/graphviz/twopi.1.en.html. – dstromberg Oct 25 '20 at 23:47
  • Thank you. That is helpful. I don't think it is the monitor or PDF viewer since I can zoom in and out. But I like the idea of trying something other than dot. – barleyguy Oct 26 '20 at 02:51
  • can you show your output (png)? – sroush Oct 26 '20 at 18:57
  • Turns out I can't embed an image, but I think I was able to successfully attach an anonymized version. It doesn't perfectly show the issue I was having, but maybe that means one of the changes I have made improved it. – barleyguy Oct 28 '20 at 03:45
  • "but the contents became blurry rather than expanding" are you planning to show this in a browser? then you should go for SVG rather than PNG – Jens Nov 02 '20 at 19:50

0 Answers0