Plot module

Functions for plotting graphs and graph properties.

note ::
For now, graph plotting is only supported when using the graph_tool library.

Content

nngt.plot.degree_distribution(network, deg_type='total', node_list=None, num_bins=50, use_weights=True, logx=False, logy=False, fignum=None, show=True)[source]

Plotting the degree distribution of a graph.

Parameters:
  • graph (Graph or subclass) – the graph to analyze.
  • deg_type (string or tuple, optional (default: “total”)) – type of degree to consider (“in”, “out”, or “total”)
  • node_list (list or numpy.array of ints, optional (default: None)) – Restrict the distribution to a set of nodes (default: all nodes).
  • use_weights (bool, optional (default: True)) – use weighted degrees (do not take the sign into account : all weights are positive).
  • logx (bool, optional (default: False)) – use log-spaced bins.
  • logy (bool, optional (default: False)) – use logscale for the degree count.
  • show (bool, optional (default: True)) – Show the Figure right away if True, else keep it warm for later use.
nngt.plot.betweenness_distribution(network, btype='both', use_weights=True, logx=False, logy=False, fignum=None, show=True)[source]

Plotting the betweenness distribution of a graph.

Parameters:
  • graph (Graph or subclass) – the graph to analyze.
  • btype (string, optional (default: “both”)) – type of betweenness to display (“node”, “edge” or “both”)
  • use_weights (bool, optional (default: True)) – use weighted degrees (do not take the sign into account : all weights are positive).
  • logx (bool, optional (default: False)) – use log-spaced bins.
  • logy (bool, optional (default: False)) – use logscale for the degree count.
  • fignum (int, optional (default: None)) – Number of the Figure on which the plot should appear
  • show (bool, optional (default: True)) – Show the Figure right away if True, else keep it warm for later use.
nngt.plot.spike_raster(spike_data, limits=None, title='Spike raster', hist=True, num_bins=1000, neural_groups=None, fignum=None, show=True)[source]

Plotting routine that constructs a raster plot along with an optional histogram.

Parameters:
  • spike_data (2D-array (numpy.array or list)) – An 2-column array containing the neuron ids in the first row and the spike times in the second.
  • limits (tuple, optional (default: None)) – Time limits of the plot (if not specified, times of first and last spike).
  • title (string, optional (default: ‘Spike raster’)) – Title of the raster plot.
  • hist (bool, optional (default: True)) – Whether to plot the raster’s histogram.
  • num_bins (int, optional (default: 1000)) – Number of bins for the histogram.
  • neural_groups (NeuralPop or list of neuron ids) – An object that defines the different neural groups to plot their spikes in different colors.
  • fignum (int, optional (default: None)) – Id of another raster plot to which the new data should be added.
  • show (bool, optional (default: True)) – Whether to show the plot right away or to wait for the next plt.show().
Returns:

fig.number (int) – Id of the matplotlib.Figure on which the raster is plotted.

nngt.plot.draw_network(network, nsize='total-degree', ncolor='group', nshape='o', nborder_color='k', nborder_width=0.5, esize=1.0, ecolor='k', spatial=True, size=(600, 600), dpi=75)[source]

Draw a given graph/network.

Parameters:
  • network (Graph or subclass) – The graph/network to plot.
  • nsize (float, array of floats or string, optional (default: “total-degree”)) – Size of the nodes; if a number, percentage of the canvas length, otherwize a string that correlates the size to a node attribute among “in/out/total-degree”, “betweenness”.
  • ncolor (float, array of floats or string, optional (default: 0.5)) – Color of the nodes; if a float in [0, 1], position of the color in the current palette, otherwise a string that correlates the color to a node attribute among “in/out/total-degree”, “betweenness” or “group”.
  • nshape (char or array of chars, optional (default: “o”)) – Shape of the nodes (see Matplotlib markers).
  • nborder_color (char, array of char, float or array of float, optional (default: “k”)) – Color of the node’s border using predefined Matplotlib colors). or floats in [0, 1] defining the position in the palette.
  • nborder_width (float or array of floats, optional (default: 0.5)) – Width of the border in percent of canvas size.
  • esize (float or array of floats, optional (default: 0.5)) – Width of the edges in percent of canvas size.
  • ecolor (char, array of char, float or array of float, optional (default: “k”)) – Edge color.
  • spatial (bool, optional (default: True)) – If True, use the neurons’ positions to draw them.
  • size (tuple of ints, optional (default: (600,600))) – (width, height) tuple for the canvas size (in px).
  • dpi (int, optional (default: 75)) – Resolution (dot per inch).