Graphviz: how to rotate a node (or a subgraph)?

sdaau picture sdaau · Dec 23, 2010 · Viewed 9.7k times · Source

I am trying to have a node (or a subgraph, enclosing a node - whichever is possible/easier) rotated, like shown in this image:

desired rotated node effect

(Note that it doesn't matter to me if the "B" label is rotated - only that the 'verti-*' texts in the record [or rather, the whole record node] are rotated as shown)

 

However, the closest I can to that, is the following dot code:

digraph graphname {
    node [fontname=Monospace, fontsize=14]; 
    subgraph clusterMasterBox {
        node [shape=record];
        l1 [label = "{ horiz-1 \r| \
 horiz-2 \r| \
 horiz-3 \r| \
 horiz-4 \r} \
"];
        subgraph clusterSubRotateBox {
            rotate=90;
            node [shape=record,rotate=90];
            l2 [label = "{ verti-1 \r| \
 verti-2 \r| \
 verti-3 \r| \
 verti-4 \r} \
"];     
            label="B";
        }
    label="A"
    }
}

The only reason I have the subgraph clusterSubRotateBox there (and the only reason why it is nested inside the clusterMasterBox), is because I hoped I could assign rotation to it, but apparently I cannot - as the above code generates this image:

gviz rotate actual

So my question is - is there a way to rotate a record node; if not on its own, then maybe as a part of subgraph (or a different kind of 'object')?

Thanks in advance for any suggestions,
Cheers!

Answer

shuva picture shuva · Jul 16, 2014

If you want to rotate a single record based node then rankdir will work. I tried it for my graph,

digraph plugnoid {
    rankdir=LR;
    node[shape=Mrecord];
    plugnoid [label="swarm| {<load0> onLoad|<plugin0> Plugin|<quit0> onQuit}|{<run0>run|<rehash0>rehash}"];}

enter image description here

The rankdir can have values LR,RL and TB(default). When I changed the rankdir to TB the output changed,

enter image description here

You may want to try them on your graph to get desired results. I experienced that when I used subgraph and set different rankdir the result was not as good. Please see http://www.graphviz.org/doc/info/shapes.html#record for more details.