nws_tools.shownet

nws_tools.shownet(A, coords, colorvec=None, sizevec=None, labels=None, threshs=[0.8, 0.3, 0], lwdths=[5, 2, 0.1], nodecmap='jet', edgecmap='jet', textscale=3)[source]

Plots a network in 3D using Mayavi

Parameters:

A : NumPy 2darray

Square N-by-N connection matrix of the network

coords: dict

Nodal coordinates of the graph. Format is

{0: (x, y, z),

{1: (x, y, z),

{2: (x, y, z),

.

.

Note that the dictionary has to have N keys.

colorvec : NumPy 1darray

Vector of color-values for each node. This could be nodal strength or modular information of nodes (i.e., to which module does node i belong to). Thus colorvec has to be of length N and all its components must be in [0,1].

sizevec : NumPy 1darray

Vector of nodal sizes. This could be degree, centrality, etc. Thus sizevec has to be of length N and all its components must be >= 0.

labels : list or NumPy 1darray

Nodal labels. Format is [‘Name1’,’Name2’,’Name3’,...] where the ordering HAS to be the same as in the coords dictionary. Note that the list/array has to have length N.

threshs : list or NumPy 1darray

Thresholds for visualization. Edges with weights larger than threshs[0] are drawn thickest, weights > threshs[1] are thinner and so on. Note that if threshs[-1]>0 not all edges of the network are plotted (since edges with 0 < weight < threshs[-1] will be ignored).

lwdths : list or NumPy 1darray

Line-widths associated to the thresholds provided by threshs. Edges with weights larger than threshs[0] are drawn with line-width lwdths[0], edges with weights > threshs[1] have line-width lwdths[1] and so on. Thus len(lwdths) == len(threshs).

nodecmap : str

Mayavi colormap to be used for plotting nodes. See Notes for details.

edgecmap : str

Mayavi colormap to be used for plotting edges. See Notes for details.

textscale : float

Scaling factor for labels (larger numbers -> larger text)

Returns:

Nothing : None

See also

show_nw
A Matplotlib based implementation with extended functionality (but MUCH slower rendering)

Notes

A list of available colormaps in Mayavi is currently available here. See the Mayavi documentation for more info.