Dot -Tjson render shows the incrorrect position compared to dot -Tpng output

Hello!

First of all, here is my .dot file (sorry about the formatting, this dot file was autogenerated)

digraph g {
#  newrank=true
  rankdir="LR";
  fontsize=20;
  labeljust="l";

  edge[style=invis, fontsize=12];
  { rank = same }

  subgraph clusterCPU {
    bgcolor=Azure;
    node [color=black,shape=box,labelloc=t];
 
  "cpu0"[label=<<FONT POINT-SIZE="10">cpu0</FONT><br/><FONT POINT-SIZE="6">Intel(R) Xeon(R)<br/>Platinum 8260 CPU<br/>2400Ghz</FONT>>]
 
  "cpu1"[label=<<FONT POINT-SIZE="10">cpu1</FONT><br/><FONT POINT-SIZE="6">Intel(R) Xeon(R)<br/>Platinum 8260 CPU<br/>2400Ghz</FONT>>]
 
  "cpu2"[label=<<FONT POINT-SIZE="10">cpu2</FONT><br/><FONT POINT-SIZE="6">Intel(R) Xeon(R)<br/>Platinum 8260 CPU<br/>2400Ghz</FONT>>]
 
  "cpu3"[label=<<FONT POINT-SIZE="10">cpu3</FONT><br/><FONT POINT-SIZE="6">Intel(R) Xeon(R)<br/>Platinum 8260 CPU<br/>2400Ghz</FONT>>]
"cpu0"->"cpu1"->"cpu2"->"cpu3" 
    label="Cpus";
  }

  subgraph clusterNetwork {
    bgcolor=lightblue;
    node [color=black,shape=box,labelloc=t];
  eth0
  eth1
"eth0"->"eth1" 
    label="Network";
  }

  subgraph clusterBlockDevices {
    bgcolor=beige 
    node [color=black,shape=box,labelloc=t];
    xvda[label=<xvda<br/>100G>]
    xvdb[label=<xvdb<br/>2G>]
    xvdh[label=<xvdh<br/>64M>]
"xvda"->"xvdb"->"xvdh"    label="Block devices";
  }

  subgraph clusterMemory {
    bgcolor=lightgreen;
    node [color=black,shape=box,labelloc=t];
    bank0[label=<bank0<br/>8188MiB>]
"bank0"    label="Memory";
  }
}

and how it looks like in png

As you can see, “cpu’” nodes are bottom of the image.

BUT, when I try to get a position of the cpu0 (for example) I get “wrong” coordinates :frowning:

$ dot -Tjson compute.dot | jq -r '.objects[] | select(.name == "cpu0").pos'
57,34

Actually, these coordinates of node “bank0”

BTW, If my compute.dot file contains only one subgraph, the output of dot -TJson command produces the right position.

I have tried this with graphviz 2.43.0 (ubuntu) and graphviz 2.50 (alpine linux), unfortunately, the result is the same

I’m not very familiar with graphiz, please shed some light on this behavior.

Thank you!

I don’t use the json output format, but I believe that a pos value of 57,34 is consistent with a node at the bottom of the graph.

So, 57,34 would roughly be .45 inches up from the bottom and .8 inches from the left.

To double-check, try dot -Tdot myfile

1 Like

@steveroush thank you for clarification!

My misunderstanding was related to how to calculate the Y coordinate.
Now, it’s works as expected :+1: