How to prevent fdp/neato from flipping coordinates?

I’m attempting to pin nodes and just re-route the edges. Unfortunately, it’s flipping the Y-axis for nodes.

According to the docs at:
nodes can be pinned with neato or fdp, though with a caveat about the origin being translated.

After 27 Feb 2014, this translation can be avoided in neato by setting notranslate=true. However, if the graph specifies node overlap removal or a change in aspect ratio, node coordinates may still change.

I’m using graphviz 2.40 and put in ‘notranslate’ and tried it with both neato and fdp. Still, the Y-axis flips.

Here’s my input.gv file:

digraph IdeaTree {
graph [ notranslate=“true” dpi=“72”]
node [ pin=“true” fixedsize=“true”]
“36047” [ pos=“196.94,-659.51!” width=“5.40” height=“3.67” label=“qwer”]
“36046” [ pos=“163.06,-132.49!” width=“5.40” height=“3.67” label=“123”]
“36047” → “36046”

As you can see, there’s no overlap or ratio given, per the warning in the docs.

But if run by:

fdp -s72 -v -Tjson -o out.json input.gv
neato -n -v -Tjson -o out.json input.gv

It generates JSON output of (showing only the relevant parts):

  "label": "qwer",
  "pin": "true",
  "id": "36047",
  "pos": "227.94,  132.49"

  "label": "123",
  "pin": "true",
  "id": "36046",
  "pos": "194.06,  659.51"

The x-coords are adjusted somewhat by graphviz, but notice how the y-coords are exchanged between the two nodes, effectively flipping my graph upside down, rotating it around the x-axis…

How can I get nodes to actually pin?

Use a newer version of Graphviz.
2.40 is rather old. You’ll get the correct answer with neato - graphviz version 2.43.0 or newer.

      "fixedsize": "true",
      "height": "3.6667",
      "label": "qwer",
      "pin": "true",
      "pos": "196.94,-659.51",
      "width": "5.4028"
1 Like

Yes, that did it. I upgraded to 2.47 and the problem went away.

Many thanks.