2
$\begingroup$

Consider this small graph with a straight edge between two nodes and another edge being a loop at one of the two vertices:

Graph[{1 -> 1, 1 -> 2}, EdgeLabels -> {(1 -> 1) -> "E1", (1 -> 2) -> "E2"}]

enter image description here

As you can see, Mathematica 11.2 places the two labels very differently for straight line edges and curved edges. One is placed on top of the edge and the other is placed far away. IMHO both should be on top of the edge by default.

How can I fix this inconsistency and adjust globally label positions for both types of edges?

It is more obvious in the full graph I am currently interested in that the labels of the curved edges should be closer to the edge itself:

enter image description here

$\endgroup$
  • 1
    $\begingroup$ This is because the curve representing the edge is smoothed, and does not go through the point coordinates describing it like it did in earlier versions (8 or 9). Try using an edge shape function that just goes through the points. (I know this is not a solution, but it's useful to know) $\endgroup$ – Szabolcs Oct 5 '18 at 9:05
  • $\begingroup$ According to the documentation to get a list of built-in settings for EdgeShapeFunction one should enter GraphElementData["Edge"]. However, this does not give me a single useful candidate. It looks like I have to write my own one. Is this correct? $\endgroup$ – Hotschke Oct 5 '18 at 12:02
1
$\begingroup$

You could try to set PerformanceGoal -> "Quality":

Graph[{1 -> 1, 1 -> 2}, 
 EdgeLabels -> {(1 -> 1) -> "E1", (1 -> 2) -> "E2"}, 
 PerformanceGoal -> "Quality"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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