plotting

Data

PILIMAGEUSE = True

__name__ = NeuroTools.plotting

Functions

check_dependency(name)

get_display(display)

Returns a pylab object with a plot() function to draw the plots.

Inputs: display - if True, a new figure is created. Otherwise, if display is a subplot object, this object is returned.

progress_bar(progress)

Prints a progress bar to stdout.

Inputs: progress - a float between 0. and 1.

Example:

progress_bar(0.7)

|=================================== |

pylab_params(fig_width_pt=246.0, ratio=0.61803398875, text_fontsize=10, tick_labelsize=8, useTex=False)

Returns a dictionary with a set of parameters that help to nicely format figures. The return object can be used to update the pylab run command parameters dictionary 'pylab.rcParams'.

Inputs: fig_width_pt - figure width in points. If you want to use your figure inside !LaTeX, get this value from !LaTeX using '\showthe\columnwidth'. ratio - ratio between the height and the width of the figure. text_fontsize - size of axes and in-pic text fonts. tick_labelsize - size of tick label font. useTex - enables or disables the use of !LaTeX for all labels and texts (for details on how to do that, see  http://www.scipy.org/Cookbook/Matplotlib/!UsingTex).

save_2D_image(mat, filename)

Saves a 2D numpy array of gray shades between 0 and 1 to a PNG file.

Inputs: mat - a 2D numpy array of floats between 0 and 1 filename - string specifying the filename where to save the data, has to end on '.png'

Example:

import numpy a = numpy.random.random([100,100]) # creates a 2D numpy array with random values between 0. and 1. save_2D_image(a,'randomarray100x100.png')

save_2D_movie(frame_list, filename, frame_duration)

Saves a list of 2D numpy arrays of gray shades between 0 and 1 to a zipped tree of PNG files.

Inputs: frame_list - a list of 2D numpy arrays of floats between 0 and 1 filename - string specifying the filename where to save the data, has to end on '.zip' frame_duration - specifier for the duration per frame, will be stored as additional meta-data

Example:

import numpy framelist = [] for i in range(100): framelist.append(numpy.random.random([100,100])) # creates a list of 2D numpy arrays with random values between 0. and 1. save_2D_movie(framelist, 'randommovie100x100x100.zip', 0.1)

set_axis_limits(subplot, xmin, xmax, ymin, ymax)

Defines the axis limits of a plot.

Inputs: subplot - the targeted plot xmin, xmax - the limits of the x axis ymin, ymax - the limits of the y axis

Example:

x = range(10) y = [] for i in x: y.append(i*i) pylab.plot(x,y) plotting.set_axis_limits(pylab, 0., 10., 0., 100.)

set_labels(subplot, xlabel, ylabel)

Defines the axis labels of a plot.

Inputs: subplot - the targeted plot xlabel - a string for the x label ylabel - a string for the y label

Example:

x = range(10) y = [] for i in x: y.append(i*i) pylab.plot(x,y) plotting.set_labels(pylab, 'x', 'y=x2')

set_pylab_params(fig_width_pt=246.0, ratio=0.61803398875, text_fontsize=10, tick_labelsize=8, useTex=False)

Updates a set of parameters within the the pylab run command parameters dictionary 'pylab.rcParams' in order to achieve nicely formatted figures.

Inputs: fig_width_pt - figure width in points. If you want to use your figure inside !LaTeX, get this value from !LaTeX using '\showthe\columnwidth' ratio - ratio between the height and the width of the figure text_fontsize - size of axes and in-pic text fonts tick_labelsize - size of tick label font useTex - enables or disables the use of !LaTeX for all labels and texts (for details on how to do that, see  http://www.scipy.org/Cookbook/Matplotlib/!UsingTex)

Classes

SimpleMultiplot

A figure consisting of multiple panels, all with the same datatype and the same x-range.

__init__(self, nrows, ncolumns, title=, xlabel=None, ylabel=None, scaling=('linear', 'linear'))

finalise(self)

Adjustments to be made after all panels have been plotted.

next_panel(self)

Changes to next panel within figure.

panel(self, i)

Returns panel i.

save(self, filename)

Saves/prints the figure to file.

Inputs: filename - string specifying the filename where to save the data

set_frame(self, ax, boollist, linewidth=2)

Defines frames for the chosen axis.

Inputs: as - the targeted axis boollist - a list linewidth - the limits of the y axis