psctb.utils.plotting package

Submodules

psctb.utils.plotting._plotting module

class psctb.utils.plotting._plotting.Data2D(mod, column_names, data_array, ltxe=None, analysis_method=None, ax_properties=None, file_name=None, additional_cat_classes=None, additional_cats=None, num_of_groups=None, working_dir=None, category_manifest=None, axvline=True)[source]

Bases: object

An object that wraps results from a PySCeS parameter scan.

Results from parameter scan or timecourse are used to initialise this object which in turn is used to create a ScanFig object. Here results can easily be accessed and saved to disk.

The Data2D is also responsible for setting up a ScanFig object from analysis results and therefore contains optional parameters for setting up this object.

Parameters
modPysMod

The model for which the parameter scan was performed.

column_nameslist of str

The names of each column in the data_array. Columns should be arranged with the input values (scan_in, time) in the first column and the output values (scan_out) in the columns that follow.

data_arrayndarray

An array containing results from a parameter scan or tome simulation. Arranged as described above.

ltxeLatexExpr, optional (DefaultNone)

A LatexExpr object that is used to convert PySCeS compatible expressions to LaTeX math. If None is supplied a new LatexExpr object will be instantiated. Sharing a single instance saves memory.

analysis_methodstr, Optional (DefaultNone)

A string that indicates the name of the analysis method used to generate the results that populate Data2D. This will determine where results are saved by Data2D as well as any ScanFig objects that are produced by it.

ax_propertiesdict, Optional (DefaultNone)

A dictionary of properties that will be used by ScanFig to adjust the appearance of plots. These properties should compatible with matplotlib.axes.AxesSubplot'' object in a way that its ``set method can be used to change its properties. If none, a default ScanFig object is produced by the plot method.

file_namestr, Optional (DefaultNone)

The name that should be prepended to files produced any ScanFig objects produced by Data2D. If None, defaults to ‘scan_fig’.

additional_cat_classesdict, Optional (DefaultNone)

A dictionary containing additional line class categories for ScanFig construction. Each data_array column contains results representing a specific category of result (elasticity, flux, concentration) which in turn fall into a larger class of data types (All Coefficients). This dictionary defines which line classes fall into which class category. (k = category class; v = line categories)

additional_catsdict, Optional (DefaultNone)

A dictionary that defines additional result categories as well as the lines that fall into these categories. (k = line category, v = lines in category).

num_of_groupsint, Optional (DefaultNone)

A number that defines the number of groups of lines. Used to ensure that the lines that are closely related (e.g. elasticities for one reaction) have colors assigned to them that are easily differentiable.

working_dirstr, Optional (DefaultNone)

This string sets the working directory directly and if provided supersedes analysis_method.

See also

ScanFig
Data2D
RateChar

Methods

plot()

Creates a ScanFig object using the data stored in the current instance of Data2D

save_results([file_name, separator, fmt])

Saves data stores in current instance of Data2D as a comma separated file.

plot()[source]

Creates a ScanFig object using the data stored in the current instance of Data2D

Returns
ScanFig

A ScanFig` object that is used to visualise results.

save_results(file_name=None, separator=',', fmt='%f')[source]

Saves data stores in current instance of Data2D as a comma separated file.

Parameters
file_namestr, Optional (DefaultNone)

The file name, extension and path under which data should be saved. If None the name will default to scan_data.csv and will be saved either under the directory specified under the directory specified in folder.

separatorstr, Optional (Default‘,’)

The symbol which should be used to separate values in the output file.

formatstr, Optional (Default‘%f’)

Format for the data.

class psctb.utils.plotting._plotting.LineData(name, x_data, y_data, categories=None, properties=None)[source]

Bases: object

An object that contains data and metadata used by ScanFig to draw a matplotlib line with interactivity.

This object is used to initialise a ScanFig object together with a Data2D object. Once a ScanFig instance is initialised, the LineData objects are saved in a list _raw_line_data. Changing any values there will have no effect on the output of the ScanFig instance. Actual x,y data, matplotlib line metadata, and ScanFig category metadata is stored.

Parameters
namestr

The name of the line. Will be used as a label if none is specified.

x_dataarray_like

The x data.

y_dataarray_like

The y data.

categorieslist, optional

A list of categories that a line falls into. This will be used by ScanFig to draw buttons that enable/disable the line.

propertiesdict, optional

A dictionary of properties of the line to be drawn. This dictionary will be used by the generic set() function of matplotlib.Lines.Line2D to set the properties of the line.

See also

ScanFig
Data2D
RateChar

Methods

add_property(key, value)

Adds a property to the properties dictionary of the LineData object.

add_property(key, value)[source]

Adds a property to the properties dictionary of the LineData object.

The properties dictionary of LineData will be used by the generic set() function of matplotlib.Lines.Line2D to set the properties of the line.

Parameters
keystr

The name of the matplotlib.Lines.Line2D property to be set.

valuesting, int, bool

The value of the property to be set. The type depends on the property.

class psctb.utils.plotting._plotting.ScanFig(line_data_list, category_classes=None, fig_properties=None, ax_properties=None, base_name=None, working_dir=None)[source]

Bases: object

Uses data in the form of a list of LineData objects to display interactive plots.

Interactive plots can be customised in terms of which data is visible at any one time by simply clicking a button to toggle a line. Matplotlib figures are used internally, therefore ScanFig figures can be altered by changing the properties of the internal figure.

Parameters
line_data_listlist of LineData objects

A LineData object contains the information needed to draw a single curve on a matplotlib figure. Here a list of these objects are used to populate the internal matplotlib figure with the various curves that represent the results of a parameter scan or simulation.

category_classesdict, Optional (DefaultNone)

Each line on a ScanFig plot falls into a different category. Each of these categories in turn fall into a different class. Each category represents a button which toggles the lines which fall into the category while the button is arranged under a label which is represented by a category class. Each key in this dict is a category class and the value is a list of categories that fall into this class. If None all categories will fall into the same class.

fig_propertiesdict, Optional (DefaultNone)

A dictionary of properties that will be used to adjust the appearance of the figure. These properties should compatible with matplotlib.figure.Figure'' object in a way that its ``set method can be used to change its properties. If None, default matplotlib figure properties will be used.

ax_propertiesdict, Optional (DefaultNone)

A dictionary of properties that will be used to adjust the appearance of plot axes. These properties should compatible with matplotlib.axes.AxesSubplot'' object in a way that its ``set method can be used to change its properties. If None default matplotlib axes properties will be used.

base_namestr, Optional (DefaultNone)

Base name that will be used when an image is saved by ScanFig. If None, then scan_fig will be used.

working_dirstr, Optional (DefaultNone)

The directory in which files figures will be saved. If None, then it will default to the directory specified in pysces.output_dir.

See also

LineData
Data2D
Attributes
categories_status
category_names
line_names

Methods

adjust_figure()

Provides widgets to set the limits and scale (log/linear) of the figure.

interact()

Displays the figure in a IPython/Jupyter notebook together with buttons to toggle the visibility of certain lines.

save([file_name, dpi, fmt, include_legend])

Saves the figure in it's current configuration.

show()

Displays the figure.

toggle_category(cat, value)

Changes the visibility of all the lines in a certain line category.

toggle_line(name, value)

Changes the visibility of a certain line.

adjust_figure()[source]

Provides widgets to set the limits and scale (log/linear) of the figure.

As with interact, the plot is displayed in the notebook. Here no widgets are provided the change the visibility of the data displayed on the plot, rather controls to set the limits and scale are provided.

See also

show
interact
property categories_status
property category_names
interact()[source]

Displays the figure in a IPython/Jupyter notebook together with buttons to toggle the visibility of certain lines.

See also

show
adjust_figure
property line_names
save(file_name=None, dpi=None, fmt=None, include_legend=True)[source]

Saves the figure in it’s current configuration.

Parameters
file_namestr, Optional (DefaultNone)

The file name to be used. If None is provided the file will be saved to working_dir/base_name.fmt

dpiint, Optional (DefaultNone)

The dpi to use. Defaults to 180.

fmtstr, Optional (DefaultNone)

The image format to use. Defaults to svg. If file_name contains a valid extension it will supersede fmt.

show()[source]

Displays the figure.

Depending on the matplotlib backend this function will either display the figure inline if running in an IPython notebook with the --pylab=inline switch or with the %matplotlib inline IPython line magic, alternately it will display the figure as determined by the rcParams['backend'] option of matplotlib. Either the inline or nbAgg backends are recommended.

toggle_category(cat, value)[source]

Changes the visibility of all the lines in a certain line category.

When used all lines in the provided category’s visibility is changed according to the value provided.

Parameters
cat: str

The name of the category to change.

value: bool

The visibility status to change the lines to (True for visible, False for invisible).

See also

toggle_line
toggle_line(name, value)[source]

Changes the visibility of a certain line.

When used a specific line’s visibility is changed according to the value provided.

Parameters
name: str

The name of the line to change.

value: bool

The visibility status to change the line to (True for visible, False for invisible).

See also

toggle_category
class psctb.utils.plotting._plotting.SimpleData2D(column_names, data_array, mod=None)[source]

Bases: object

Methods

plot()

Creates a ScanFig object using the data stored in the current instance of Data2D

save_results([file_name, separator, fmt])

Saves data stores in current instance of Data2D as a comma separated file.

plot()[source]

Creates a ScanFig object using the data stored in the current instance of Data2D

Returns
ScanFig

A ScanFig` object that is used to visualise results.

save_results(file_name=None, separator=',', fmt='%f')[source]

Saves data stores in current instance of Data2D as a comma separated file.

Parameters
file_namestr, Optional (DefaultNone)

The file name, extension and path under which data should be saved. If None the name will default to scan_data.csv and will be saved either under the directory specified under the directory specified in folder.

separatorstr, Optional (Default‘,’)

The symbol which should be used to separate values in the output file.

fmtstr, Optional (Default‘%f’)

Format for the data.

psctb.utils.plotting._plotting.load_data2d(file_name, mod=None, ltxe=None)[source]

Loads a gzipped cPickle file containing a Data2D object. Optionally a model can be provided (which is useful when loading data that reference the same model. For the same reason a LatexExpr object can be supplied.

psctb.utils.plotting._plotting.save_data2d(data_2dobj, file_name)[source]

Saves a Data2D object to a gzipped cPickle to a specified file name.

Module contents