Is there an easy way to rotate around the X-axis?

In other words, swap Y pos values of topmost and bottom-most nodes and extrapolate in-between.

Assuming you are using dot, add rankdir=BT (see rankdir | Graphviz)

I have client-side code for further drag-and-drop editing after a graphviz layout. For reasons I won’t go into, that code has the origin defined differently than graphviz, so everything is flipped. I want to export a layout directly from graphviz. In order to match the client, it would need to be flipped.

I already did a substitution, if rankdir=BT make it TB, and vs., but I use circo and twopi in addition to dot, so that won’t work for those. Actually, in order to exactly match any editing changes that have been made on the client, I may use fdp with pin=true, rather than dot/circo/twopi. But the same need for flipping would apply.

Essentially, I’m wanting to redefine the origin in graphviz.

This is only lightly tested, but it seems to work:

  1. use any engine, but set output format to dot (DOT | Graphviz) (e.g. twopi -Tdot myfile >myfile.out1)
  2. use the GVPR ( program (see below) to change the sign of the Y component of each node’s pos (pos | Graphviz) value. (e.g. gvpr -c -f flip.gvpr myfile.out1 >myfile.out2)
  3. run that output into neato -n (FAQ | Graphviz). Neato will re-establish all the edge and misc. label positions. (e.g. neato -n -Tpng myfile.out2 >myfile.png)


  //print("// old bb: ", $;
  $$ + "," + "-" + yOf(llOf($ + "," + xOf(urOf($ + "," + "-" + yOf(urOf($;  
  //print("// new bb: ", $;
  //print("// old pos: ", $.pos);
  $.pos=(string)$.X + "," + (string)(- $.Y);
  //print("// new pos: ", $.pos);
1 Like

So far your solution works on every graph I’ve tried it on. Much appreciated.