简体   繁体   中英

Vertical and horizontal headers with Graphviz

I need to create a vertical and horizontal header with Graphviz, but I do not know how to make the two subgraphs have different orientation. I have tried with rankdir but apparently it does not work with subgraphs. I have no idea how to proceed. I appreciate any help.

digraph Table{
    node[shape=box style=filled fillcolor=olivedrab2]
    //rankdir=TB
    subgraph Rows{
     rankdir=TB
     A[label="A"]
     B[label="B"]
     C[label="C"]
     D[label="D"]
     E[label="E"]
     F[label="F"]       
     A->B
     B->A
     B->C
     C->B
     C->D
     D->C
     D->E
     E->D
     E->F
     F->E
     {rank=same A B C D E F}
 }
subgraph Column{
    rankdir=LR
    M[label="M"]
    N[label="N"]
    O[label="O"]
    P[label="P"]
    Q[label="Q"]
    R[label="R"]        
    M->N
    //N->M
    N->O
    //O->N
    O->P
    //P->O
    P->Q
    //Q->P
    Q->R
    //R->Q
    {rank=same M N O P Q R}
  }
 }

Something like this

You almost did everything right. Just remove the {rank=same MNOPQR} line.

You are correct, rankdir works only for the whole graph, it won't work for subgraphs separately. But you can control position of nodes using:

  • rank =same attribute of subgraph

which forces all nodes mentioned in subgraph to be at the same level.

which allows you to connect two nodes but not affect their position by this connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM