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, 16 Apr 2020 23:54:13 +0200Changing display labels of nodes on a graphhttps://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/ Hi,
I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?
ThanksWed, 15 Apr 2020 09:33:36 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/Comment by oldani for <p>Hi,
I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50793#post-id-50793The idea is the following.
Let's imagine I have defined the graph : G2 = Graph([('a', 'b', 'edge label')]). Like that it is displayed with node labels 'a' et 'b'.
But I want to display G2 (as it is defined) but as G3 = Graph([('Good', 'Morning')]) will be displayedThu, 16 Apr 2020 15:24:20 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50793#post-id-50793Comment by slelievre for <p>Hi,
I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50797#post-id-50797The structure and meaning of your last sentence escape me.Thu, 16 Apr 2020 17:50:05 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50797#post-id-50797Comment by oldani for <p>Hi,
I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50802#post-id-50802Mmmh sorry for my bad english. I found finally another way to solve my problem, I think there was no solution to what I wanted to do. Thanks a lot for your time.Thu, 16 Apr 2020 23:54:13 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50802#post-id-50802Comment by slelievre for <p>Hi,
I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50774#post-id-50774Can you provide a small example to illustrate what you have and what you want in a simple case?Thu, 16 Apr 2020 00:09:09 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50774#post-id-50774Answer by Sébastien for <p>Hi,
I have created a graph which is in fact a tree. Each node has a label that I gave at creation time. Now, when I plot the graph for each node this "internal" label is displayed. Is it possible to have different display labels than this "internal" label?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?answer=50784#post-id-50784One possibility is that you are specifying the edge labels, not the vertex labels:
sage: G = Graph([('a', 'b', 'edge label')])
sage: G.plot(edge_labels=True)
![image description](/upfiles/15870227478796016.png)
Since edge labels are not shown by default, what you see in `G.plot()` are the vertex labels only (that you call "internal").Thu, 16 Apr 2020 09:40:16 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?answer=50784#post-id-50784Comment by oldani for <p>One possibility is that you are specifying the edge labels, not the vertex labels:</p>
<pre><code>sage: G = Graph([('a', 'b', 'edge label')])
sage: G.plot(edge_labels=True)
</code></pre>
<p><img alt="image description" src="/upfiles/15870227478796016.png"></p>
<p>Since edge labels are not shown by default, what you see in <code>G.plot()</code> are the vertex labels only (that you call "internal").</p>
https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50790#post-id-50790Oh! yes good idea, if I remove the node labels and keep only edge labels can be a way to go.
ThanksThu, 16 Apr 2020 15:10:43 +0200https://ask.sagemath.org/question/50764/changing-display-labels-of-nodes-on-a-graph/?comment=50790#post-id-50790