Drawing a graph - different size node label for each node

642 views
Skip to first unread message

PT

unread,
Nov 6, 2011, 9:56:52 AM11/6/11
to networkx-discuss
Hi,

In my graph, I have the size of each node scaled based on a relevant
value for my purposes. But for visualization, I think it would be nice
to have the node label font size scale in the same way - having a huge
node labeled in the same font size as a small node looks a little
strange for me.

It doesn't say that I can pass an array (/list) into
networkx.draw_networkx_labels(font_size=)... this only accepts an
integer argument. Is there any way around this, without iterating
through the Graph instance and the positions and doing it manually in
a loop?

/Phil

Aric Hagberg

unread,
Nov 6, 2011, 12:08:38 PM11/6/11
to networkx...@googlegroups.com

Unfortunately there isn't a way to pass an array of font sizes.
You'll have to loop over each node and add the text with size. Last I
checked matplotlib didn't have a concept of a collection of text
objects so I think writing a loop is the only simple solution.

Aric

Reply all
Reply to author
Forward
0 new messages