How to set bend direction for edges with splines="curved" in GraphViz? (using neato)
Asked Answered
B

1

8

I am creating a graph with manually positioned nodes and use the splines="curved" type of edges between them.

digraph graphname {
  splines="curved";
  node[shape = box, margin="0.03,0.03", fontsize=11, height=0.1, width=0.1,  fixedsize=false];

  "LeftFoot\nRightHand" [pos="-150,-150!"];
  "RightFoot\nRightHand" [pos="-90,-150!"];
  "LeftFoot\nRightFoot" [pos="0,-150!"];
  ...

  edge[style = solid,fontsize=11];
  "LeftFoot\nRightFoot":n -> "RightFoot\nRightHand":n [label = "3", penwidth = 1, color = "red"];
  "LeftFoot\nRightFoot":s -> "LeftFoot\nRightHand":s [label = "7", penwidth = 1, color = "red"];
  ...
}

The problem is that one of the edges is bent to the wrong side, so it passes through a node: Screenshot from graph

Is there an easy way to fix this, like e.g. "bend left" or "bend right" in TikZ?

I tried to use the pos attribute on the edge to set a spline control point to change the bend, however this does not appear to change the edge at all.

Brainard answered 18/6, 2015 at 13:39 Comment(0)
N
1

In Grapvhiz 2.38 this seems to be fixed. I've scaled the pos slightly but left the rest of the code alone:

Dot source:

digraph graphname {
  splines="curved";
  node[shape = box, margin="0.03,0.03", fontsize=11, height=0.1, width=0.1,  fixedsize=false];

  "LeftFoot\nRightHand" [pos="-2,-2!"];
  "RightFoot\nRightHand" [pos="-1.2,-2!"];
  "LeftFoot\nRightFoot" [pos="0,-2!"];

  edge[style = solid,fontsize=11];
  "LeftFoot\nRightFoot":n -> "RightFoot\nRightHand":n [label = "3", penwidth = 1, color = "red"];
  "LeftFoot\nRightFoot":s -> "LeftFoot\nRightHand":s [label = "7", penwidth = 1, color = "red"];

}

Command:

dot -Kneato -Tpng input.gv > output.png

Output:
enter image description here

Newbold answered 19/6, 2020 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.