Stuart Golodetz
Stuart Golodetz

Reputation: 20656

Can I auto-fit the width of Graphviz nodes using dot?

Please does anyone know if there's a way to make Graphviz's dot program (note: not neato, although I'd also be somewhat interested in answers for that) auto-fit the width of nodes to accommodate the labels I specify? At the moment I have this

digraph
{
    node [shape=record];
    n [label="This is a very long caption"];
}

but the node ends up too small to accommodate the caption:

Bad Graphviz output

I found an option called fixedsize, which in theory I should be able to set to false in order to make the nodes expand to fit their labels:

http://www.graphviz.org/doc/info/attrs.html#d:fixedsize

Unfortunately, it doesn't work, as this gives me the same result:

digraph
{
    node [shape=record, fixedsize=false];
    n [label="This is a very long caption"];
}

Any ideas please?

Upvotes: 5

Views: 5809

Answers (1)

marapet
marapet

Reputation: 56526

The node label width in your example actually does auto-fit when using dot.

fixedsize=false (default) and any given value for width however should yield the given value for width if the output format is dot:

Note also that, if the output format is dot, the value given to width will be the final value.

There may be a problem with your version of graphviz - did you try using a recent version?

Upvotes: 2

Related Questions