You're reading the documentation for a development version. For the latest released version, please have a look at v0.1.

fitpy.plotting module

Graphical presentation of the results of fitting models to datasets.

Fitting itself is a quite complicated process, and it is crucial for routine use to have graphical representations of the results, besides automatically generated reports (see the reports module) that usually contain such graphical representations.

Typically, graphical representations of fit results will contain both, the original data and the fitted model, at least as long as datasets with 1D data are concerned. Additionally, one may be interested in plotting the residual as well.

Technically, the plotters in the FitPy package rely on the additional properties of the fitpy.dataset.CalculatedDataset class, particularly the property residual within the data property. Therein the residual of the fit is stored, and thus, the original data can simply be recovered by adding the residual to the fitted model contained in the data of the dataset.

Types of plots

Generally, at least two types of plotters can be distinguished with respect to the kind of information that should be represented graphically:

  • Graphical representation of both, data and fitted model

    The simplest type of such a plotter displays both, data and fitted model in one axis, perhaps with the residual in a second, smaller axes underneath.

    For 2D datasets, things become more complicated, but here, at least fitted model and residual can be plotted in two axes.

  • Graphical representation of the reliability and quality of fits

    Particularly for robust fits including LHS or similar sampling methods, a graphical representation of the quality of the fit (e.g., the fitness value plotted as function of the index of the sample) is of great value.

Module documentation

class fitpy.plotting.SinglePlotter1D[source]

Bases: aspecd.plotting.SinglePlotter1D

1D plots of single datasets, including original data and fitted model.

Convenience class taking care of 1D plots of single datasets. The type of plot can be set in its aspecd.plotting.SinglePlotter1D.type attribute. Allowed types are stored in the aspecd.plotting.SinglePlotter1D.allowed_types attribute.

Additionally to the functionality of the superclass, this plotter displays the (experimental) data together with the fitted model.

properties

Properties of the plot, defining its appearance

For the properties that can be set this way, see the documentation of the fitpy.plotting.SinglePlot1DProperties and aspecd.plotting.SinglePlot1DProperties classes.

Type

SinglePlot1DProperties

data_drawing

Actual graphical representation of the data

Type

matplotlib.artist.Artist

Examples

For convenience, a series of examples in recipe style (for details of the recipe-driven data analysis, see aspecd.tasks) is given below for how to make use of this class. Of course, all parameters settable for the superclasses can be set as well. The examples focus each on a single aspect.

Note

Usually, you will have set another ASpecD-derived package as default package in your recipe for processing and analysing your data. Hence, you need to provide the package name (fitpy) in the kind property, as shown in the examples.

In the simplest case, just invoke the plotter with default values:

- kind: fitpy.singleplot
  type: SinglePlotter1D
  properties:
    filename: output.pdf
static applicable(data)[source]

Check whether plot is applicable to the given dataset.

Returns

applicableTrue if successful, False otherwise.

Return type

bool

class fitpy.plotting.SinglePlot1DProperties[source]

Bases: aspecd.plotting.SinglePlot1DProperties

Properties of a 1D single plot, defining its appearance.

Additionally to the properties of the superclass, properties particularly for displaying both, data and fitted model exist.

Furthermore, some sensible settings for both, data and fitted model, are provided, such as labels and line colours. Of course, you can override these values manually.

data

Properties of the line representing the data.

“Data” here refers to the data the model has been fitted to.

For the properties that can be set this way, see the documentation of the aspecd.plotting.LineProperties class.

Type

aspecd.plotting.LineProperties

apply(plotter=None)[source]

Apply properties to plot.

Parameters

plotter (SinglePlotter1D) – Plotter the properties should be applied to.