Display labels in line with the edge when using Graphviz

GraphvizLabels

Graphviz Problem Overview


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.

Graphviz Solutions


Solution 1 - Graphviz

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

Solution 2 - Graphviz

Edit: another answer found an option that now exists to align text with edges.

Your best option may be to export the graph as an SVG and use Illustrator or Inkscape to fine-tune it. This is only practical when producing a few graphs.

I frequently have to tweak the output from Graphviz and Gephi; they give me a good starting point though.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmnemonicView Question on Stackoverflow
Solution 1 - GraphvizmalbarboView Answer on Stackoverflow
Solution 2 - GraphvizGalaxView Answer on Stackoverflow