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:
objectAn 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
ScanFigobject. Here results can easily be accessed and saved to disk.The
Data2Dis also responsible for setting up aScanFigobject 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 byData2Das well as anyScanFigobjects that are produced by it.- ax_propertiesdict, Optional (DefaultNone)
A dictionary of properties that will be used by
ScanFigto adjust the appearance of plots. These properties should compatible withmatplotlib.axes.AxesSubplot'' object in a way that its ``setmethod can be used to change its properties. If none, a defaultScanFigobject is produced by theplotmethod.- file_namestr, Optional (DefaultNone)
The name that should be prepended to files produced any
ScanFigobjects produced byData2D. If None, defaults to ‘scan_fig’.- additional_cat_classesdict, Optional (DefaultNone)
A dictionary containing additional line class categories for
ScanFigconstruction. Eachdata_arraycolumn 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.
Methods
plot()Creates a
ScanFigobject using the data stored in the current instance ofData2Dsave_results([file_name, separator, fmt])Saves data stores in current instance of
Data2Das a comma separated file.- plot()[source]¶
Creates a
ScanFigobject using the data stored in the current instance ofData2D- Returns
ScanFigA ScanFig` object that is used to visualise results.
- save_results(file_name=None, separator=',', fmt='%f')[source]¶
Saves data stores in current instance of
Data2Das 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:
objectAn object that contains data and metadata used by
ScanFigto draw amatplotlibline with interactivity.This object is used to initialise a
ScanFigobject together with aData2Dobject. Once aScanFiginstance is initialised, theLineDataobjects are saved in a list_raw_line_data. Changing any values there will have no effect on the output of theScanFiginstance. Actual x,y data,matplotlibline metadata, andScanFigcategory 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 ofmatplotlib.Lines.Line2Dto set the properties of the line.
Methods
add_property(key, value)Adds a property to the
propertiesdictionary of theLineDataobject.- add_property(key, value)[source]¶
Adds a property to the
propertiesdictionary of theLineDataobject.The
propertiesdictionary ofLineDatawill be used by the genericset()function ofmatplotlib.Lines.Line2Dto set the properties of the line.- Parameters
- keystr
The name of the
matplotlib.Lines.Line2Dproperty 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:
objectUses 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 ``setmethod 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 ``setmethod 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, thenscan_figwill 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.
- Attributes
- categories_status
- category_names
- line_names
Methods
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.
- 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
- 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. Iffile_namecontains a valid extension it will supersedefmt.
- show()[source]¶
Displays the figure.
Depending on the matplotlib backend this function will either display the figure inline if running in an
IPythonnotebook with the--pylab=inlineswitch or with the %matplotlib inline IPython line magic, alternately it will display the figure as determined by thercParams['backend']option ofmatplotlib. Either the inline or nbAgg backends are recommended.See also
- 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
valueprovided.- 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(name, value)[source]¶
Changes the visibility of a certain line.
When used a specific line’s visibility is changed according to the
valueprovided.- 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
- class psctb.utils.plotting._plotting.SimpleData2D(column_names, data_array, mod=None)[source]¶
Bases:
objectMethods
plot()Creates a
ScanFigobject using the data stored in the current instance ofData2Dsave_results([file_name, separator, fmt])Saves data stores in current instance of
Data2Das a comma separated file.- plot()[source]¶
Creates a
ScanFigobject using the data stored in the current instance ofData2D- Returns
ScanFigA ScanFig` object that is used to visualise results.
- save_results(file_name=None, separator=',', fmt='%f')[source]¶
Saves data stores in current instance of
Data2Das 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.