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.Mon, 31 Mar 2014 09:29:48 +0200Graph theory: Make vertex labels in plots biggerhttps://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/Is it possible to make the labels for the vertices of graphs bigger? I can make the vertices themselves bigger but that doesn't seem to change the size of the labels.
Thank you.Wed, 12 Dec 2012 16:51:15 +0100https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/Answer by alejandroerickson for <p>Is it possible to make the labels for the vertices of graphs bigger? I can make the vertices themselves bigger but that doesn't seem to change the size of the labels.</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?answer=16107#post-id-16107One way is to use figsize to indirectly change the relative size of the labels.
P = graphs.PetersenGraph()
P.show(figsize=[1,1],vertex_size=0,layout='spring')
The output of this is:
![Mangled Petersen graph with large labels.](http://www.alejandroerickson.com/home/blog/im/petersen_labels.png)Mon, 31 Mar 2014 09:29:48 +0200https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?answer=16107#post-id-16107Answer by ppurka for <p>Is it possible to make the labels for the vertices of graphs bigger? I can make the vertices themselves bigger but that doesn't seem to change the size of the labels.</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?answer=14367#post-id-14367I have opened [#13827](http://trac.sagemath.org/13827) for this.Wed, 12 Dec 2012 21:18:39 +0100https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?answer=14367#post-id-14367Answer by Bétréma for <p>Is it possible to make the labels for the vertices of graphs bigger? I can make the vertices themselves bigger but that doesn't seem to change the size of the labels.</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?answer=14371#post-id-14371Imho it's easier to write a few lines of code to plot graphs using plotting primitives, something like code below. S denotes my graph (a simple dictionary, for each key u, S[u] is the list of neighbours), xy is a dictionary which indicates positions of vertices, defined elsewhere as are ms (vertex size) and fs (font size).
G = Graphics()
p = [xy[u] for u in S]
c = [my_color(u) for u in S]
G += scatter_plot (p, markersize = ms, facecolor = c, **kwds)
for u in S:
for v in S[u]:
G += line ([xy[u], xy[v]])
G += sum (text (my_str(u), xy[u], fontsize = fs, zorder = 10) for u in S)
It's that simple, and anything (position, size, color of vertices, font size, text to display for each vertex) is under control.Thu, 13 Dec 2012 07:01:41 +0100https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?answer=14371#post-id-14371Comment by G-Sage for <p>Imho it's easier to write a few lines of code to plot graphs using plotting primitives, something like code below. S denotes my graph (a simple dictionary, for each key u, S[u] is the list of neighbours), xy is a dictionary which indicates positions of vertices, defined elsewhere as are ms (vertex size) and fs (font size).</p>
<pre><code> G = Graphics()
p = [xy[u] for u in S]
c = [my_color(u) for u in S]
G += scatter_plot (p, markersize = ms, facecolor = c, **kwds)
for u in S:
for v in S[u]:
G += line ([xy[u], xy[v]])
G += sum (text (my_str(u), xy[u], fontsize = fs, zorder = 10) for u in S)
</code></pre>
<p>It's that simple, and anything (position, size, color of vertices, font size, text to display for each vertex) is under control.</p>
https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?comment=18524#post-id-18524It may be easier if you know how to do it. :) I could learn a thing or two from studying your code. For me, it's easier for ppurka to make a tracticket and create a new feature :) The problem is it'll take 1 month before it's on our Sage server, but I don't need it that badly. All kidding aside, though this is more of an advanced technique for someone like me, this is a very good thing to know. So, thanks for your answer.Thu, 13 Dec 2012 14:04:03 +0100https://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/?comment=18524#post-id-18524