Display labels in line with the edge when using Graphviz

mnemonic picture mnemonic · May 17, 2013 · Viewed 9.1k times · Source

I am using Graphviz 2.30. Horizontal positioning for labels works out, but in a few cases, a modified angle would be desired.

For instance, I tried various values for angle here but without any effect:

ABB -> ABACUS[label="applied", fontname="Arial", fontsize=15, labelangle=110];

How can I display labels in line with (i.e. parallel to) the edge when using a Graphviz digraph.

The entire digraph will not be posted due to an NDA. In addition, the rotation will be applied only to a few labels.

I have read similar threads like this or another (or a thread about alignment for instance) but without any help regarding my issue.

Answer

malbarbo picture malbarbo · Apr 26, 2016

Using dot2latex allows you to specify lblstyle attribute. The value of lblstyle is used by PGF/TikZ in pdf generation.

One can specify parallel labels like this:

digraph G {
    edge [lblstyle="above, sloped"];
    a -> b [label="ab"];
    b -> c [label="bc"];
    c -> a [label="ca"];
}

To generate the pdf

$ dot2tex --tikzedgelabel file.dot > file.tex
$ pdflatex file.tex

The result is

enter image description here