Trekkie
Trekkie

Reputation: 994

How can I adjust a GraphViz render

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.

Upvotes: 1

Views: 1364

Answers (2)

Jamison Jiang
Jamison Jiang

Reputation: 53

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

Upvotes: 4

sroush
sroush

Reputation: 6773

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 Board\n@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

Upvotes: 3

Related Questions