nws_tools.show_nw

nws_tools.show_nw(A, coords, colorvec=None, sizevec=None, labels=None, nodecmap=<matplotlib.colors.LinearSegmentedColormap object>, edgecmap=<matplotlib.colors.LinearSegmentedColormap object>, linewidths=None, nodes3d=False, viewtype='axial')[source]

Matplotlib-based plotting routine for networks

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.

nodecmap : Matplotlib colormap

Colormap to use for plotting nodes

edgecmap : Matplotlib colormap

Colormap to use for plotting edges

linewidths : NumPy 2darray

Same format and nonzero-pattern as A. If no linewidhts are provided then the edge connecting nodes v_i and v_j is plotted using the linewidth A[i,j]. By specifying, e.g., linewidhts = (1+A)**2, the thickness of edges in the network-plot can be scaled.

nodes3d : bool

If nodes3d=True then nodes are plotted using 3d spheres in space (with diameters = sizevec). If nodes3d=False then the Matplotlib scatter function is used to plot nodes as flat 2d disks (faster).

viewtype : str

Camera position, viewtype can be one of the following

axial (= axial_t) : Axial view from top down

axial_t : Axial view from top down

axial_b : Axial view from bottom up

sagittal (= sagittal_l) : Sagittal view from left

sagittal_l : Sagittal view from left

sagittal_r : Sagittal view from right

coronal (= coronal_f) : Coronal view from front

coronal_f : Coronal view from front

coronal_b : Coronal view from back

Returns:

Nothing : None

See also

shownet
A Mayavi based implementation with less functionality but MUCH faster rendering

Notes

See Matplotlib’s mplot3d tutorial