Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I plot the following graph with an EdgeRenderingFunction, the position of both the labels are at dead center, and with a large graph I have the labels completely overlapping each other:

GraphPlot[{{1 -> 2, "a"}, {2 -> 1, "b"}}, 
  DirectedEdges -> True, VertexCoordinateRules -> Automatic, VertexLabeling -> True, 
  EdgeRenderingFunction -> ({Blue, Arrow[#1, 0.1],
     If[#3 =!= None, Text[Style[#3, Medium], Mean[#1], Background -> White], {}]} &)]

Mathematica graphics

Is there a way to position the labels, say, at 60% down the edge instead of dead center, so that the labels don't have a chance to overlap? I've been toggling with Mean[#1] above but can't get this right positioning.

Edit: improved formatting

share|improve this question
Edit: The following is a hackish way to do it: If[Length[#1] > 2, Mean[#1] + (#1[[1]] - #1[[2]])*0.5, Mean[#1]], but I would be open to more suggestions. – user10245 Oct 28 '13 at 5:36
Also hackish: Mean[#1[[4 ;;]]] – Simon Woods Oct 28 '13 at 14:09
Graph[{1 \[DirectedEdge] 2, 2 \[DirectedEdge] 1}, 
 VertexLabels -> "Name", 
 EdgeLabels -> {1 \[DirectedEdge] 2 -> Placed["a", {1/2, {1, 1.5}}], 
   2 \[DirectedEdge] 1 -> Placed["b", {1/2, {1, 1.5}}]}]

enter image description here

share|improve this answer
Is this the new font default for v10 or did you set fontfamily beforehand? I would welcome a default sans serif label style! – István Zachar Nov 27 '13 at 15:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.