Using ruby-graphviz, I've created a graph that looks like this (border added to emphasize rendering boundaries):
What I really want is for A and K to line up together at the top (or left, if rankdir="LR"). So I added an invisible node (call it X), and added invisible edges from X to A and K. And here's what I got:
X, XA, and XK have no labels, and style set to 'invis'. X has height, width, and margin set to 0, and fixedsize set to true. XA and XK have minlen, len, and penwidth set to 0.
But there's still that empty space at the top. Is there any way to get rid of it, short of cropping after the fact?
You do not need invisible nodes to achieve this.
This is the dot syntax to force the same rank for two nodes:
{rank=same; A; K;}
This is called a subgraph.
I don't know ruby-graphviz, I'm not sure how to create a subgraph - but there is an example on github:
c2 = g.subgraph { |c|
c[:rank => "same"]
c.mysite[:label => "\nexample.com\n ", :shape => "component", :fontname => "Arial"]
c.dotgraph[:label => "\ndotgraph.net\n ", :shape => "component", :fontname => "Arial"]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With