Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz graph positioning xlabels

Tags:

graphviz

I have tried using xlp and also followed this graphviz thread (http://www.graphviz.org/content/how-use-xlp-attribute-positioning-external-labels-xlabel), but neither have actually worked.

This is my dot code:

digraph {     forcelabels=true;     rankdir=LR;     graph[ranksep=1,nodesep=.5];     node[shape=box];     "start" [xlabel="start",xlp="0,0",shape=doublecircle,label=" "];     "requested"->"fault";     "requested"->"progress";     "start"->"requested";     "progress"->"fault";     "progress"->"progress";     "progress"->"complete";     "fault" [xlabel="fault",shape=doublecircle,label=" "];     "complete" [xlabel="complete",shape=doublecircle,label=" "]; } 

And this is what it looks like: enter image description here

Ideally start,fault, and complete would just be directly under the nodes, but I can't seem to postion the xlabels correctly.

like image 264
user1634494 Avatar asked Jun 07 '15 02:06

user1634494


1 Answers

If you use neato with the -n2 flag, you should be able to set the position of xlabel. You would need to specify the position of every node, though.

So if you had a file called lb.gv with the following contents:

digraph{     forcelabels=true;     rankdir=LR;     graph[ranksep=1,nodesep=.5,margin=0.3,bgcolor=Transparent];      node[shape=box];     start [pos="0,0", xlp="23,54", xlabel=start, shape=doublecircle, label= " "];     requested [pos="100,0"];     progress [pos="250,-66"];     fault [pos="400,70", xlp="424,124", xlabel=fault, shape=doublecircle,label= " "];     complete [pos="400,-66", xlp="424,-10", xlabel=complete, shape=doublecircle,label= " "];     requested->fault;     requested->progress;     start->requested;     progress->fault;     progress:w->progress:_;     progress->complete; } 

You could run neato -n2 -Tpng lb.gv > test.png

That's what I got:

graphviz

like image 162
Ivan Chaer Avatar answered Sep 22 '22 07:09

Ivan Chaer