brian2tools.plotting.data module

Module to plot simulation data (raster plots, etc.)

brian2tools.plotting.data.plot_raster(spike_indices, spike_times, time_unit=<Mock name='mock.ms' id='140308607353488'>, axes=None, **kwds)[source]

Plot a “raster plot”, a plot of neuron indices over spike times. The default marker used for plotting is '.', it can be overriden with the marker keyword argument.

Parameters:
  • spike_indices (ndarray) – The indices of spiking neurons, corresponding to the times given in spike_times.
  • spike_times (Quantity) – A sequence of spike times.
  • time_unit (Unit, optional) – The unit to use for the time axis. Defaults to ms, but longer simulations could use second, for example.
  • axes (Axes, optional) – The Axes instance used for plotting. Defaults to None which means that a new Axes will be created for the plot.
  • kwds (dict, optional) – Any additional keywords command will be handed over to matplotlib’s plot command. This can be used to set plot properties such as the color.
Returns:

axes – The Axes instance that was used for plotting. This object allows to modify the plot further, e.g. by setting the plotted range, the axis labels, the plot title, etc.

Return type:

Axes

brian2tools.plotting.data.plot_state(times, values, time_unit=<Mock name='mock.ms' id='140308607353488'>, var_unit=None, var_name=None, axes=None, **kwds)[source]
Parameters:
  • times (Quantity) – The array of times for the data points given in values.
  • values (Quantity, ndarray) – The values to plot, either a 1D array with the same length as times, or a 2D array with len(times) rows.
  • time_unit (Unit, optional) – The unit to use for the time axis. Defaults to ms, but longer simulations could use second, for example.
  • var_unit (Unit, optional) – The unit to use to plot the values (e.g. mV for a membrane potential). If none is given (the default), an attempt is made to find a good scale automatically based on the values.
  • var_name (str, optional) – The name of the variable that is plotted. Used for the axis label.
  • axes (Axes, optional) – The Axes instance used for plotting. Defaults to None which means that a new Axes will be created for the plot.
  • kwds (dict, optional) – Any additional keywords command will be handed over to matplotlib’s plot command. This can be used to set plot properties such as the color.
Returns:

axes – The Axes instance that was used for plotting. This object allows to modify the plot further, e.g. by setting the plotted range, the axis labels, the plot title, etc.

Return type:

Axes

brian2tools.plotting.data.plot_rate(times, rate, time_unit=<Mock name='mock.ms' id='140308607353488'>, rate_unit=<Mock name='mock.Hz' id='140308607354512'>, axes=None, **kwds)[source]
Parameters:
  • times (Quantity) – The time points at which the rate is measured.
  • rate (Quantity) – The population rate for each time point in times
  • time_unit (Unit, optional) – The unit to use for the time axis. Defaults to ms, but longer simulations could use second, for example.
  • time_unit – The unit to use for the rate axis. Defaults to Hz.
  • axes (Axes, optional) – The Axes instance used for plotting. Defaults to None which means that a new Axes will be created for the plot.
  • kwds (dict, optional) – Any additional keywords command will be handed over to matplotlib’s plot command. This can be used to set plot properties such as the color.
Returns:

axes – The Axes instance that was used for plotting. This object allows to modify the plot further, e.g. by setting the plotted range, the axis labels, the plot title, etc.

Return type:

Axes