Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz: label on the left side

in case I use the following Graphviz code, a simple graph will be created which shows the label on the right hand side.

digraph lable_on_the_right_side {

   /* define nodes */

   node [color=lightblue2, style=filled, fontname=Arial];

   a [label="S1"];
   b [label="S2"];


   /* define edges */

   a -> b [label="Label on the right side"]

}

Rendered Dot Code as Image

Is it possible to let the label appear on the left side instead? If yes, what would the code need to look like?

like image 503
Rainer Deussen Avatar asked May 03 '13 11:05

Rainer Deussen


1 Answers

There aren't many ways to change the position of the text of an edge label - you could try to add some extra empty spaces to label... Sometimes also double edges have the effect of having one label to the right, the other one to the left.

Still hacky, but at least repeatable, you may use a headlabel (or taillabel) and then use labelangle together with labeldistance to position the label where you'd like:

a -> b [
        headlabel="Label on the left side" 
        labeldistance=7.5 
        labelangle=75
       ]

enter image description here

With a little trial and error you may place the label where needed.

like image 113
marapet Avatar answered Oct 26 '22 21:10

marapet