This module contains a collection of tools for plotting and image processing that shall facilitate the generation and handling of your data visualizations. It utilizes the Matplotlib and the Python Imaging Library (PIL) packages.
The following functions might be useful for every user of the Matplotlib package.
A pylab object with a plot() function to draw the plots.
Prints a progress bar to stdout, filled to the given ratio.
Example of usage:
>>> progress_bar(0.7)
|=================================== |
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’.
Defines the axis limits in a plot.
Example of usage:
>>> 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.)
Defines the axis labels of a plot.
Example of usage:
>>> x = range(10)
>>> y = []
>>> for i in x: y.append(i*i)
>>> pylab.plot(x,y)
>>> plotting.set_labels(pylab, 'x', 'y=x^2')
Updates a set of parameters within the the pylab run command parameters dictionary ‘pylab.rcParams’ in order to achieve nicely formatted figures.
Saves a 2D numpy array of gray shades between 0 and 1 to a PNG file.
Example of usage:
>>> 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')
Saves a list of 2D numpy arrays of gray shades between 0 and 1 to a zipped tree of PNG files.
Example of usage:
>>> 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)
This class creates a figure consisting of multiple panels, all with the same datatype and the same x-range.
Here is an example of creating a SimpleMultiplot object:
>>> nrows = 4
>>> ncolumns = 5
>>> title = 'a SimpleMultiplot'
>>> xlabel = 'the x axis'
>>> ylabel = 'the y axis'
>>> scaling = ('linear','log')
>>> smp = SimpleMultiplot(nrows=self.nrows, ncolumns=self.ncolumns, title=title, xlabel=xlabel, ylabel=ylabel, scaling=scaling)
Handles to panels can be directly accessed by their indices via the function call panel(i) or by stepping iteratively through them with function next_panel().
The frames surrounding a panel can be defined with the function set_frame(ax, boollist, linewidth), where ax is the handle to the panel of choice, boollist is a list of four booleans defining if [bottom, left, top, right] of the panel shall have a frame line with width linewidth.
Once a SimpleMultiplot is ready to be saved, calling finalise() will turn off tick labels for all x-axes except the bottom one. The whole plot is saved to a filename and type of choice with the call save(filename).
This module contains a collection of tools for plotting and image processing that shall facilitate the generation and handling of NeuroTools data visualizations. It utilizes the Matplotlib and the Python Imaging Library (PIL) packages.
SimpleMultiplot - object that creates and handles a figure consisting of multiple panels, all with the same datatype and the same x-range.
get_display - returns a pylab object with a plot() function to draw the plots. progress_bar - prints a progress bar to stdout, filled to the given ratio. pylab_params - returns a dictionary with a set of parameters that help to nicely format figures by updating the pylab run command parameters dictionary ‘pylab.rcParams’. set_axis_limits - defines the axis limits in a plot. set_labels - defines the axis labels of a plot. set_pylab_params - updates a set of parameters within the the pylab run command parameters dictionary ‘pylab.rcParams’ in order to achieve nicely formatted figures. save_2D_image - saves a 2D numpy array of gray shades between 0 and 1 to a PNG file. save_2D_movie - saves a list of 2D numpy arrays of gray shades between 0 and 1 to a zipped tree of PNG files.
A figure consisting of multiple panels, all with the same datatype and the same x-range.
Returns a pylab object with a plot() function to draw the plots.
Prints a progress bar to stdout.
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’.
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).
Saves a 2D numpy array of gray shades between 0 and 1 to a PNG file.
Saves a list of 2D numpy arrays of gray shades between 0 and 1 to a zipped tree of PNG files.
Defines the axis limits of a plot.
Defines the axis labels of a plot.
Updates a set of parameters within the the pylab run command parameters dictionary ‘pylab.rcParams’ in order to achieve nicely formatted figures.
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)