netpyne.plotting.plotter

Module for plotting analysed data

Classes:

MetaFigure(kind[, sim, subplots, sharex, ...])

NetPyNE object to hold a figure along with its axes, settings, and standardized methods

GeneralPlotter(data, kind[, axis, twinx, ...])

NetPyNE object to hold a Matplotlib axis along with its settings and standardized methods

ScatterPlotter(data[, axis])

NetPyNE plotter for scatter plots

LinePlotter(data[, axis, options])

NetPyNE plotter for plotting one line per axis

LinesPlotter(data[, axis, options])

NetPyNE plotter for plotting multiple lines on the same axis

HistPlotter(data[, axis, options])

NetPyNE plotter for histogram plotting

ImagePlotter(data[, axis, options])

NetPyNE plotter for image plotting using plt.imshow

class netpyne.plotting.plotter.MetaFigure(kind, sim=None, subplots=None, sharex=False, sharey=False, rcParams=None, autosize=0.35, **kwargs)[source]

Bases: object

NetPyNE object to hold a figure along with its axes, settings, and standardized methods

Parameters
  • kind (str) – The kind of figure, used in saving

  • subplots (int, list) –

    The number of subplots in the figure. If an int, it is the number of rows of subplots. If a list, specifies [nrows, ncols].

    Default: None creates a figure with one axis.

  • sharex (bool or {'none', 'all', 'row', 'col'}) – Controls sharing of properties among x (sharex) or y (sharey) axes: True or ‘all’: x- or y-axis will be shared among all subplots. False or ‘none’: each subplot x- or y-axis will be independent. ‘row’: each subplot row will share an x- or y-axis. ‘col’: each subplot column will share an x- or y-axis. When subplots have a shared x-axis along a column, only the x tick labels of the bottom subplot are created. Similarly, when subplots have a shared y-axis along a row, only the y tick labels of the first column subplot are created. To later turn other subplots’ ticklabels on, use tick_params. Default: False

  • sharey (bool or {'none', 'all', 'row', 'col'}) – Controls sharing of properties among x (sharex) or y (sharey) axes: True or ‘all’: x- or y-axis will be shared among all subplots. False or ‘none’: each subplot x- or y-axis will be independent. ‘row’: each subplot row will share an x- or y-axis. ‘col’: each subplot column will share an x- or y-axis. When subplots have a shared x-axis along a column, only the x tick labels of the bottom subplot are created. Similarly, when subplots have a shared y-axis along a row, only the y tick labels of the first column subplot are created. To later turn other subplots’ ticklabels on, use tick_params. Default: False

  • rcParams (dict) – A dictionary containing any or all Matplotlib settings to use for this figure. To see all settings and their defaults, execute import matplotlib; matplotlib.rcParams.

  • autosize (float) –

    Automatically increases figure size by this fraction when there are multiple subplots to reduce white space between axes. Set to False or 0.0 to turn off.

    Default: 0.35 increases figure size.

  • figSize (list) –

    Size of figure in inches [width, height].

    Default: Matplotlib default.

  • dpi (int) –

    Resolution of figure in dots per inch.

    Default: Matplotlib default.

Methods:

saveFig([sim, fileName, fileDesc, fileType, ...])

Method to save the figure

showFig(**kwargs)

Method to display the figure

reshowFig(**kwargs)

Method to display the figure after it has been closed

addSuptitle(**kwargs)

Method to add a super title to the figure

finishFig(**kwargs)

Method to finalize a figure

saveFig(sim=None, fileName=None, fileDesc=True, fileType='png', fileDir=None, overwrite=True, **kwargs)[source]

Method to save the figure

Parameters
  • fileName (str) –

    Name of the file to be saved.

    Default: None uses the name of the simulation from simConfig.filename.

  • fileDesc (str) –

    Description of the file to be saved.

    Default: True uses metaFig.kind.

  • fileType (str) –

    Type of file to save figure as.

    Default: 'png' Options: 'eps': ‘Encapsulated Postscript’, 'jpg': ‘Joint Photographic Experts Group’, 'jpeg': ‘Joint Photographic Experts Group’, 'pdf': ‘Portable Document Format’, 'pgf': ‘PGF code for LaTeX’, 'png': ‘Portable Network Graphics’, 'ps': ‘Postscript’, 'raw': ‘Raw RGBA bitmap’, 'rgba': ‘Raw RGBA bitmap’, 'svg': ‘Scalable Vector Graphics’, 'svgz': ‘Scalable Vector Graphics’, 'tif': ‘Tagged Image File Format’, 'tiff': ‘Tagged Image File Format’

  • fileDir (str) –

    Directory where figure is to be saved.

    Default: None uses the current directory.

  • overwrite (bool) –

    Whether to overwrite an existing figure with the same name.

    Default: True overwrites.

showFig(**kwargs)[source]

Method to display the figure

reshowFig(**kwargs)[source]

Method to display the figure after it has been closed

addSuptitle(**kwargs)[source]

Method to add a super title to the figure

Parameters
  • t (str) – The suptitle text.

  • x (float) – The x location of the text in figure coordinates. Default: 0.5

  • y (float) – The y location of the text in figure coordinates. Default: 0.98

  • horizontalalignment ({'center', 'left', 'right'}) – The horizontal alignment of the text relative to (x, y). Default: ‘center’

  • ha ({'center', 'left', 'right'}) – The horizontal alignment of the text relative to (x, y). Default: ‘center’

  • verticalalignment ({'top', 'center', 'bottom', 'baseline'}) – The vertical alignment of the text relative to (x, y). Default: ‘top’

  • va ({'top', 'center', 'bottom', 'baseline'}) – The vertical alignment of the text relative to (x, y). Default: ‘top’

  • fontsize (rcParams["figure.titlesize"]) – The font size of the text. See Text.set_size for possible values. Default: ‘large’

  • sizedefault (rcParams["figure.titlesize"]) – The font size of the text. See Text.set_size for possible values. Default: ‘large’

  • fontweight (rcParams["figure.titleweight"]) – The font weight of the text. See Text.set_weight for possible values. Default: ‘normal’

  • weightdefault (rcParams["figure.titleweight"]) – The font weight of the text. See Text.set_weight for possible values. Default: ‘normal’

finishFig(**kwargs)[source]

Method to finalize a figure

Adds supertitle, tight_layout, saves fig, shows fig as per kwarg inputs.

Parameters
  • suptitle (dict) – Dictionary with values for supertitle.

  • tightLayout (bool) – Whether to apply tight_layout. Default: True

  • saveFig (bool) – Whether to save the figure. Default: False

  • showFig (bool) – Whether to display the figure. Default: False

class netpyne.plotting.plotter.GeneralPlotter(data, kind, axis=None, twinx=False, twiny=False, sim=None, rcParams=None, metafig=None, **kwargs)[source]

Bases: object

NetPyNE object to hold a Matplotlib axis along with its settings and standardized methods

Parameters
  • data (dict, str) – The data to be used in the plot. If a str, it must be the path and filename of a previously saved data set.

  • kind (str) – The kind of figure, used in saving.

  • axis (matplotlib axis) – The axis to plot into. If axis is set to None, a new figure and axis are created and plotted into.

  • twinx (bool) – If plotting into an existing axis, whether to twin that x axis (i.e. allow plotting at a different y scale). Default: False

  • twiny (bool) – If plotting into an existing axis, whether to twin that y axis (i.e. allow plotting at a different x scale). Default: False

  • rcParams (dict) – A dictionary containing any or all Matplotlib settings to use for this figure. To see all settings and their defaults, execute import matplotlib; matplotlib.rcParams.

Methods:

loadData(fileName[, fileDir, sim])

Method to load data from file

saveData([fileName, fileDesc, fileType, ...])

Method to save data to file

formatAxis(**kwargs)

Method to format the axis

addLegend([handles, labels])

Method to add a legend to the axis

addScalebar([matchx, matchy, hidex, hidey, ...])

Method to add a scale bar to the axis

addColorbar(**kwargs)

Method to add a color bar to the axis

finishAxis(**kwargs)

Method to finalize an axis

loadData(fileName, fileDir=None, sim=None)[source]

Method to load data from file

Parameters
  • fileName (str) – Name of the file to be loaded.

  • fileDir (str) –

    Path of the file to be loaded.

    Default: None uses the current directory.

saveData(fileName=None, fileDesc=None, fileType=None, fileDir=None, sim=None, **kwargs)[source]

Method to save data to file

Parameters
  • fileName (str) –

    Name of the file to be saved.

    Default: None uses simConfig.filename.

  • fileDesc (str) –

    String to be appended to fileName.

    Default: None adds the ‘kind’ of MetaFigure.

  • fileType (str) –

    Extension of file type to save.

    Default: None chooses automatically.

  • fileDir (str) –

    Path to save the file to.

    Default: None uses the current directory.

formatAxis(**kwargs)[source]

Method to format the axis

Parameters
  • title (str) – Title to add to the axis.

  • xlabel (str) – Label to add to the x axis.

  • ylabel (str) – Label to add to the y axis.

  • ylabelRight (bool) – Whether to move y label to the right side. Default: False keeps the y label on the left.

  • xlim (list) – [min, max] for x axis.

  • ylim (list) – [min, max] for y axis.

  • invert_yaxis (bool) – Whether to invert the y axis.

addLegend(handles=None, labels=None, **kwargs)[source]

Method to add a legend to the axis

Parameters
  • handles (list) –

    List of Matplotlib legend handles.

    Default: None finds handles in the current axis.

  • labels (list) –

    List of Matplotlib legend labels.

    Default: None finds labels in the current axis.

  • legendKwargs (dict) – Dictionary of Matplotlib legend parameters with their values.

  • kwargs (str) – You can enter any Matplotlib legend parameter as a kwarg. See https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.legend.html

addScalebar(matchx=True, matchy=True, hidex=True, hidey=True, unitsx=None, unitsy=None, scalex=1.0, scaley=1.0, xmax=None, ymax=None, space=None, **kwargs)[source]

Method to add a scale bar to the axis

Parameters
  • matchx (bool) –

    If True, set size of scale bar to spacing between ticks, if False, set size using sizex params.

    Default: True

  • matchy (bool) –

    If True, set size of scale bar to spacing between ticks, if False, set size using sizey params.

    Default: True

  • sizex (float) – The size of the x scale bar if matchx is False.

  • sizey (float) – The size of the y scale bar if matchy is False.

  • hidex (bool) –

    Whether to hide the x-axis labels and ticks.

    Default: True

  • hidey (bool) –

    Whether to hide the x-axis labels and ticks.

    Default: True

  • unitsx (str) –

    The units to use on the scale bar label.

    Default: None

  • unitsy (str) –

    The units to use on the scale bar label.

    Default: None

  • scalex (float) –

    Desired scaling in x direction.

    Default: 1.0

  • scaley (float) –

    Desired scaling in y direction.

    Default: 1.0

  • xmax (float) –

    Maximum size of x scale bar.

    Default: None

  • ymax (float) –

    Maximum size of y scale bar.

    Default: None

  • space (float) –

    Amount of space to add to y axis for scale bar.

    Default: None

addColorbar(**kwargs)[source]

Method to add a color bar to the axis

Parameters

kwargs (str) – You can enter any Matplotlib colorbar parameter as a kwarg. See https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.colorbar.html

finishAxis(**kwargs)[source]

Method to finalize an axis

Parameters
  • saveData (bool) – Whether to save the data. Default: False

  • legend (bool, dict) – Whether to add a legend. If a dict, must be legend parameters and their values. Default: False

  • scalebar (bool, dict) – Whether to add a scale bar. If a dict, must be scalebar parameters and their values. Default: False

  • colorbar (bool, dict) – Whether to add a color bar. If a dict, must be colorbar parameters and their values. Default: False

  • grid (bool, dict) – Whether to add a grid lines to the axis. If a dict, must be grid parameters and their values. Default: False

class netpyne.plotting.plotter.ScatterPlotter(data, axis=None, **kwargs)[source]

Bases: netpyne.plotting.plotter.GeneralPlotter

NetPyNE plotter for scatter plots

Methods:

plot(**kwargs)

plot(**kwargs)[source]
class netpyne.plotting.plotter.LinePlotter(data, axis=None, options={}, **kwargs)[source]

Bases: netpyne.plotting.plotter.GeneralPlotter

NetPyNE plotter for plotting one line per axis

Methods:

plot(**kwargs)

plot(**kwargs)[source]
class netpyne.plotting.plotter.LinesPlotter(data, axis=None, options={}, **kwargs)[source]

Bases: netpyne.plotting.plotter.GeneralPlotter

NetPyNE plotter for plotting multiple lines on the same axis

Methods:

plot(**kwargs)

plot(**kwargs)[source]
class netpyne.plotting.plotter.HistPlotter(data, axis=None, options={}, **kwargs)[source]

Bases: netpyne.plotting.plotter.GeneralPlotter

NetPyNE plotter for histogram plotting

Methods:

plot(**kwargs)

plot(**kwargs)[source]
class netpyne.plotting.plotter.ImagePlotter(data, axis=None, options={}, **kwargs)[source]

Bases: netpyne.plotting.plotter.GeneralPlotter

NetPyNE plotter for image plotting using plt.imshow

Methods:

plot(**kwargs)

plot(**kwargs)[source]