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

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):

I understand that this is caused by the fact that xlabel
s 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.
回答1:
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.
来源:https://stackoverflow.com/questions/20910932/xlabels-for-nodes-overlap-with-edges-in-dot