ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 05 Jun 2014 23:35:51 +0200getting edge labels in a digraph to display properlyhttps://ask.sagemath.org/question/9245/getting-edge-labels-in-a-digraph-to-display-properly/I am new to Sage, and I am trying to get the program to display labeled digraphs the way that I want them. I give Sage the code:
sage: g = DiGraph({0:{1:'x',2:'z',3:'a'}, 2:{5:'out'}});
sage: g.show(edge_labels=True)
When I do this, the graph is displayed with the edge labels, but the labels appear right on top of the edges, which makes the labels hard to read. How do I get the program to display the edge labels right next to the edge, rather than on them? Any help will be appreciated.Sun, 19 Aug 2012 15:27:24 +0200https://ask.sagemath.org/question/9245/getting-edge-labels-in-a-digraph-to-display-properly/Answer by calc314 for <p>I am new to Sage, and I am trying to get the program to display labeled digraphs the way that I want them. I give Sage the code:</p>
<pre><code>sage: g = DiGraph({0:{1:'x',2:'z',3:'a'}, 2:{5:'out'}});
sage: g.show(edge_labels=True)
</code></pre>
<p>When I do this, the graph is displayed with the edge labels, but the labels appear right on top of the edges, which makes the labels hard to read. How do I get the program to display the edge labels right next to the edge, rather than on them? Any help will be appreciated.</p>
https://ask.sagemath.org/question/9245/getting-edge-labels-in-a-digraph-to-display-properly/?answer=13946#post-id-13946I'm not an expert in the graph theory portion of Sage, but here is what I've found. The position of the label appears to be hard-coded in as the midpoint between the vertices, which is what you want to change. If you look at the answer to [Font Size for Edge Label](http://ask.sagemath.org/question/664/font-size-for-edge-label), you'll see there is a line of code that includes a `text` command. The first argument of the `text` command is the text to be displayed (the edge label in this case) and the second argument is the position. You'll see the position is programmed to be the midpoint of the edge. You could modify this position to move the label away from the edge.
I realize this is not a pretty solution. Perhaps someone will suggest something simpler.
Sun, 19 Aug 2012 21:33:36 +0200https://ask.sagemath.org/question/9245/getting-edge-labels-in-a-digraph-to-display-properly/?answer=13946#post-id-13946Comment by kcrisman for <p>I'm not an expert in the graph theory portion of Sage, but here is what I've found. The position of the label appears to be hard-coded in as the midpoint between the vertices, which is what you want to change. If you look at the answer to <a href="http://ask.sagemath.org/question/664/font-size-for-edge-label">Font Size for Edge Label</a>, you'll see there is a line of code that includes a <code>text</code> command. The first argument of the <code>text</code> command is the text to be displayed (the edge label in this case) and the second argument is the position. You'll see the position is programmed to be the midpoint of the edge. You could modify this position to move the label away from the edge.</p>
<p>I realize this is not a pretty solution. Perhaps someone will suggest something simpler.</p>
https://ask.sagemath.org/question/9245/getting-edge-labels-in-a-digraph-to-display-properly/?comment=16166#post-id-16166Something like this is now http://trac.sagemath.org/ticket/16450Thu, 05 Jun 2014 23:35:51 +0200https://ask.sagemath.org/question/9245/getting-edge-labels-in-a-digraph-to-display-properly/?comment=16166#post-id-16166