Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xlabels for nodes overlap with edges in dot

Tags:

graphviz

dot

I try to use dot for drawing a graph, and I have the following problem

graph

The label for node b overlaps with the edge from a to b. Is there a way to move this label somehow to avoid this?

This is the code I use to generate the image (using dot)

digraph A {
  rankdir=LR;
  center=true; margin=0.3; 
  nodesep=1.5; ranksep=0.5;

  node [shape=point,  height=".2", width=".2"];

  a [xlabel="a"];
  b [xlabel="b"];
  c [xlabel="c"];
  a -> b -> c;
  a -> c;
}

This happens quite often and it's annoying (same here, but with edges):

enter image description here

I understand that this is caused by the fact that xlabels are put after all the things were laid out, but I was wondering if it's possible to help it a bit - i.e. say it where the label needs to be placed.

like image 969
Alexey Grigorev Avatar asked Jan 03 '14 19:01

Alexey Grigorev


1 Answers

You can't do this -- you want to provide position information for the xlabel, but graphviz does not currently (2016-01-25) allow this. There is an open feature request in the graphviz bug tracker for this ability; it is described as:

this is basically a feature request for allowing the user to provide position information for xlabels. For xlabels attached to nodes, the coordinates should be relative to the node position. A similar feature could hold for head and tail labels for edges. I suppose xlabels for edges could be based on the "center" of the edge.

like image 140
mtd Avatar answered Oct 08 '22 06:10

mtd