Sh4pe
Sh4pe

Reputation: 1876

Make boxes of the same width

I'm trying to make a flowchart. In this flowchart, I want to have boxed nodes with varying labels (and thus varying label sizes), but I want the nodes to have the same size.

The source code is the following:

digraph G {

    a0 [ label="this is a loooong label" ]
    a3 [ label="short label" ]

    b0 [ label="this is a long label" ]
    b3 [ label="short label" ]

    a0, a1, a2, a3 [ shape=box ]
    b0, b1, b2, b3 [ shape=box ]

    subgraph cluster_one {
        style=filled;
        color=lightgrey;

        a0 -> a1 -> a2 -> a3;

        label = "This is nice and grey";
    }

    subgraph cluster_two {
        b0 -> b1 -> b2 -> b3;
        label = "This is nice and white";
        color=blue;
    }

}

I get this image:

Flowchart

I want the boxes in the subgraphs to have the same width. How can I do this?

Thank you in advance :)

Upvotes: 0

Views: 607

Answers (2)

Hauke Ingmar Schmidt
Hauke Ingmar Schmidt

Reputation: 11607

You can set default values for nodes via node [width=5]. this sets the minimum size. If you set fixed-size=true this will be the actual size.

Upvotes: 2

Fabian Steeg
Fabian Steeg

Reputation: 45714

You can define a global node style, like this:

digraph G {

  node[width=4]
  ...

Upvotes: 0

Related Questions