xlabels for nodes overlap with edges in dot
Asked Answered
G

1

12

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.

Gearalt answered 3/1, 2014 at 19:4 Comment(2)
what is the command you use to generate the plot?Stringy
#30690033Laliberte
N
6

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.

Northumbrian answered 26/1, 2016 at 4:11 Comment(2)
It is currently possible to position everything as mentioned at https://mcmap.net/q/745741/-graphviz-graph-positioning-xlabels with neato -n2, but then you have to place everything explicitly, which is a pain, and half defeats the purpose of graphviz...Laliberte
Indeed, that almost entirely defeats the purpose of graphviz. It's like saying "you can get from New York to Los Angeles with this broken car, you just have to carry the car yourself".Northumbrian

© 2022 - 2024 — McMap. All rights reserved.