networkx graphs and alpha transparency...

3,151 views
Skip to first unread message

nickschurch

unread,
Feb 25, 2010, 8:55:43 AM2/25/10
to networkx-discuss
Can I set the transparency of any individual edge or node, much like I
can set the colour of any edge or node, or is it a single value for a
single layer?

nickschurch

unread,
Feb 25, 2010, 9:44:05 AM2/25/10
to networkx-discuss
It'd be nice to be able to specify the edge width for individual edges
too.

Aric Hagberg

unread,
Feb 25, 2010, 9:52:02 AM2/25/10
to networkx...@googlegroups.com


You can currently do both of those with multiple calls to
draw_networkx_nodes(...,nodelist=)
or
draw_networkx_edges(...,edgelist=)
specifying only the nodes or edges you want drawn.

The networkx maptlotlib drawing module needs a redesign to
include the ability to handle individual node and edge attributes.
But that hasn't happened yet...

Aric

nickschurch

unread,
Feb 26, 2010, 7:10:45 AM2/26/10
to networkx-discuss
Thanks aric, I think I'll wait for the redesign - I don't want to call
the draw commands 13k times!

On Feb 25, 2:52 pm, Aric Hagberg <ahagb...@gmail.com> wrote:

Christopher Ellison

unread,
Feb 26, 2010, 1:12:53 PM2/26/10
to networkx...@googlegroups.com

It looks like the current version does this fine and that the
documentation is in error. Nick, try the following:

import matplotlib.pyplot as plt
import numpy as np
import networkx as nx

g = nx.generators.complete_graph(3)
pos = nx.layout.spring_layout(g)
edgewidths = [1,3,5]
edgecolors = [(1,0,0,.5), (1,0,0,1),(0,0,1,1)]
nodesizes = np.array([1, .5, 2]) * 300

nx.draw_networkx_edges(g, pos, width=edgewidths,
edge_color=edgecolors)

nx.draw_networkx_nodes(g, pos, node_size=nodesizes,
linewidth=edgewidths,
node_color=edgecolors)

plt.show()

Chris

Reply all
Reply to author
Forward
0 new messages