skip to Main Content

I’m trying to render a tree that is very broad… and it renders, as expected, in a long, skinny horizontal image.

Problem is that I need a graph suitable for a document. I would very much like to take and move the nodes that are rendered horizontally and "drag" them down so that the graph is more vertical… with the edges curving to accommodate this. Are there any clever ways to accomplish this? GraphViz settings? Third party tools that let me manipulate and fine tune the output? I work mostly in the Python ecosystem, but open to others. Also open to the use of tools like Visio and other pro drawing tools. Thanks!

Edit

After implementing the answer below by @sroush, and then tweaking a little further with Photoshop, got some nice results.

Tweaking the above in Photosop. Had to add the two curved edges after the secondary node by hand, but it’s worth it. Much more presentable.

2

Answers


  1. I assume you are using dot, and your graph "naturally" has only a few ranks (rows).
    There are a few tweaks that will help a bit (reducing node horizontal footprints):

    • node [shape=rect] // snugger fit into rectangles
    • insert newlines into node labels e.g. xxx [label="Controller Boardn@19_8"])

    Also try the unflatten program (https://www.graphviz.org/pdf/unflatten.1.pdf). It will increase the apparent number of ranks (rows).

    See related question here with command line examples:
    Distribute nodes on the same rank of a wide graph to different lines

    Login or Signup to reply.
  2. You can use the minlen property to limit the minimum level span of some edges.This avoids the result becoming very long in the horizontal position.
    For example:

    digraph {
    a->b
    a->c
    a->d
    a->e
    }
    

    This will output the following image:
    enter image description here

    But when minlen is used, the picture will become longer vertically but shortened horizontally:

    digraph {
    a->b
    a->c
    a->d[minlen=2]
    a->e[minlen=3]
    }
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search