Troy Daniels
Troy Daniels

Reputation: 3598

Make a Graphviz plot more square

I am trying to make plot of several disconnected graphs.

digraph {
    // rankdir=RL
    subgraph template {
        node [shape=square]
        edge [color=black]
        subgraph top {
            node [group=1]
        A
        B
        C
        D
        E
    }
    subgraph bottom {
        node  [group=2]
        F
        G
        H
        }
    }

    C -> c
    F -> f
    subgraph s1 {
        edge [color=red]
        A -> a
        B -> b1
        D -> d1
        E -> e1
        G -> g1
        H -> h1
        }
    subgraph s2 {
        edge [color=blue]
        A -> b1
        B -> a
        D -> d2
        E -> e2
        G -> g2
        H -> h2
    }

    subgraph s3 {
        edge [color=green]
        A -> a
        B -> b1
        D -> d2
        E -> e3
        G -> g3
        H -> h1
    }

    subgraph s4  {
        edge [color=purple]
        A -> b1
        B -> a
        D -> e1
        E -> e2
        G -> g4
        H -> h1
    }
    subgraph s5 {
        edge [ color=orange]
        A -> b1
        B -> a
        D -> d5
        E -> e1
        G -> g5
        H -> h1
    }

    subgraph s6 {
        edge [ color=brown]
        A -> a
        B -> b1
        D -> d1
        E -> e6
        G -> g6
        H -> h1
    }
    subgraph s6 {
        edge [ color=tan]
        A -> a
        B -> b2
        D -> d2
        E -> e6
        G -> g6
        H -> h1
    }
}

This creates a short, wide graph.

Short, wide graph

I would like to have a taller, narrower graph. For example, moving the F, G and H trees under the A-E nodes would be good.

I tried size, which just made the nodes bigger or smaller.

I tried ratio, which stretched the graph but did not move nodes around.

I tried using group and/or rankdir, but neither did what I wanted.

I have mostly tried using fdp, but also tried dot.

I am happy with a solution that either automatically moves the nodes around or requires me to manually move them.

Any suggestions on how to achieve this?

Upvotes: 0

Views: 550

Answers (1)

sroush
sroush

Reputation: 6773

Here are two ways:

  • (easiest)
  • OR
    • use invisible edges to connect the nodes from one cluster to another a->C. Unfortunately, this quickly becomes tedious, trying to get all the nodes to line up as you want.

Upvotes: 1

Related Questions