How to get different ranksep for certain ranks
Asked Answered
D

2

8

I want my bottom rank of nodes to have smaller ranksep than the rest of my graph. How do you do this? I can't seem to find the right syntax to set ranksep separately for different subgraphs.

This is not working - all ranks are separated the same (both the big ranksep and small ranksep are ignored):

graph G{
  {  ranksep=1.0; // big separation
     1 -- 2
     1 -- 3
  }
  {  ranksep=0.2;  // small separation
     2 -- 4
     2 -- 5
     3 -- 6
     3 -- 7
  }
}

Result:

ranksep

Dukey answered 17/9, 2013 at 21:8 Comment(0)
P
6

ranksep is an graph attribute (not subgraph), and cannot be used to vary the distance between ranks within the same graph in dot.

Plover answered 17/9, 2013 at 22:55 Comment(2)
Well that's a bummer. Could this be simulated with invisible nodes?Dukey
You should be able to add an invisible rank by inserting invisible nodes (a vertical column above node 4 for example). Or you may try adding an invisible node to the same rank and apply some margin (maybe with shape=none, label=" ", margin=1). Or you use gvpr to change the position of the lowest nodes and render the resulting graph with neato.Plover
W
3

You can specifiy a minimum length for an edge. From dotguide : "minlen defines the minimum difference between the ranks of the head and tail". Note that you'll may have to tune both ranksep (global) and minlen to tune the aspect of your graph.

graph G{
  ranksep=0.1;  // small separation
  {  
     1 -- 2 [ minlen =4]
     1 -- 3 [ minlen =4]
  }
  {  
     2 -- 4
     2 -- 5
     3 -- 6
     3 -- 7
  }
}

Result : edge min length

Wesleywesleyan answered 13/3, 2018 at 20:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.