Node line color and style customizable ?

678 views
Skip to first unread message

Pierre Besson

unread,
Feb 17, 2012, 6:30:47 AM2/17/12
to networkx...@googlegroups.com
Hello,

I would like to customize the color, and why not the style, of a node's border. In the draw_networkx_nodes doc, it seems that we can set the color inside a node, its shape and the width of its border, but we can't play with border's color.

Is there a way to do so ?

Thank you

Aric Hagberg

unread,
Feb 17, 2012, 8:26:08 AM2/17/12
to networkx...@googlegroups.com

Yes, with matplotlib everything is possible.

The draw_networkx_nodes() function returns a collection object that
you can modify, e.g.

In [1]: import networkx as nx

In [2]: import pylab

In [3]: G=nx.path_graph(3)

In [4]: pos=nx.spring_layout(G)

In [5]: nodes = nx.draw_networkx_nodes(G,pos)

In [6]: nodes.set_edgecolor('r')

In [7]: pylab.draw()

You can set the colors, linestyle, zorder, etc, that way.

Aric

Reply all
Reply to author
Forward
0 new messages