# 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.

edit retag close merge delete

Sort by » oldest newest most voted

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).

    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.

more

It 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.

( 2012-12-13 14:04:03 +0200 )edit

I have opened #13827 for this.

more

One 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:

more