clophfit.fitting.plotting#

Provide utilities for creating various types of plots used in this project.

Primary functions encompassed are:

plot_spectra: Develops a plot for spectral data. Each line is colored based on a designated colormap. plot_autovectors: Plots the autovectors. plot_autovalues: Plots the singular values from SVD. plot_fit: Plots residuals for each dataset with uncertainty. plot_pca: Plots the first two principal components. plot_spectra_distributed: Plots spectra from titration distributing on the figure top. plot_emcee: Plots emcee result. plot_emcee_k_on_ax: Plots emcee result for a specific parameter on an axis. distribute_axes: Positions axes evenly along the horizontal axis of the figure.

The module uses several dependencies such as ArviZ, numpy, pandas, seaborn, lmfit, matplotlib, and uncertainties. Moreover, it includes a range of internal project modules and a specific color map for PCA components and LM fit.

Helper Functions:

_apply_common_plot_style: Applies grid style, title, and labels to a plot. _create_spectra_canvas: Creates figure and axes for spectra plot.

Classes:

PlotParameters: Parameters for plotting, depending on whether the data is pH or Cl.

Classes#

PlotParameters

Parameters for plotting, depending on whether the data is pH or Cl.

Functions#

distribute_axes(fig, num_axes)

Position axes evenly along the horizontal axis of the figure.

plot_autovalues(ax, s)

Plot the singular values from SVD.

plot_autovectors(ax, wl, u)

Plot autovectors.

plot_pca(ax, v, conc, pp)

Plot the first two principal components.

plot_spectra(ax, spectra, pp)

Plot spectra.

plot_spectra_distributed(fig, titration, pp[, dbands])

Plot spectra from titration distributing on the top of the figure top.

plot_emcee(flatchain)

Plot emcee result.

plot_emcee_k_on_ax(ax, res_emcee[, p_name])

Plot emcee result.

plot_fit(ax, ds, params[, nboot, pp])

Plot fitted curves and data points with uncertainty on a given Axes.

plot_fit_gemini(ax, ds, params[, nboot, pp])

Plot fitted curves and data points on a given axis.

print_emcee(result_emcee)

Print maximum likelihood estimation (MLE) results from an emcee fitting.

Module Contents#

class clophfit.fitting.plotting.PlotParameters#

Parameters for plotting, depending on whether the data is pH or Cl.

clophfit.fitting.plotting.distribute_axes(fig, num_axes)#

Position axes evenly along the horizontal axis of the figure.

Parameters:
  • fig (Figure) – The Figure object on which the Axes objects are drawn.

  • num_axes (int) – The number of Axes objects to position.

Returns:

A list of positioned Axes objects.

Return type:

list[Axes]

clophfit.fitting.plotting.plot_autovalues(ax, s)#

Plot the singular values from SVD.

Parameters:
  • ax (Axes) – The mpl.axes.axes on which to plot the singular values.

  • s (ArrayF) – The singular values from the SVD.

Return type:

None

clophfit.fitting.plotting.plot_autovectors(ax, wl, u)#

Plot autovectors.

Parameters:
  • ax (Axes) – The mpl.axes.Axes object to which the plot should be added.

  • wl (pd.Index[int]) – The index of spectra data frame.

  • u (ArrayF) – The left singular vectors obtained from SVD.

Return type:

None

clophfit.fitting.plotting.plot_pca(ax, v, conc, pp)#

Plot the first two principal components.

Parameters:
  • ax (Axes) – The mpl.axes.Axes object to which the plot should be added.

  • v (ArrayF) – The matrix containing the principal components.

  • conc (ArrayF) – The concentrations used for the titration.

  • pp (PlotParameters) – The PlotParameters object containing plot parameters.

Return type:

None

clophfit.fitting.plotting.plot_spectra(ax, spectra, pp)#

Plot spectra.

Parameters:
  • ax (Axes) – The Mpl.Axes.Axes object to which the plot should be added.

  • spectra (pd.DataFrame) – The DataFrame containing spectral data.

  • pp (PlotParameters) – The PlotParameters object containing plot parameters.

Return type:

None

clophfit.fitting.plotting.plot_spectra_distributed(fig, titration, pp, dbands=None)#

Plot spectra from titration distributing on the top of the figure top.

Parameters:
  • fig (matplotlib.figure.Figure)

  • titration (dict[str, pandas.DataFrame])

  • pp (PlotParameters)

  • dbands (dict[str, tuple[int, int]] | None)

Return type:

None

clophfit.fitting.plotting.plot_emcee(flatchain)#

Plot emcee result.

Parameters:

flatchain (pandas.DataFrame)

Return type:

matplotlib.figure.Figure

clophfit.fitting.plotting.plot_emcee_k_on_ax(ax, res_emcee, p_name='K')#

Plot emcee result.

Parameters:
  • ax (matplotlib.axes.Axes)

  • res_emcee (lmfit.minimizer.MinimizerResult)

  • p_name (str)

Return type:

None

clophfit.fitting.plotting.plot_fit(ax, ds, params, nboot=0, pp=None)#

Plot fitted curves and data points with uncertainty on a given Axes.

Parameters:
  • ax (Axes) – The matplotlib axis to plot on.

  • ds (Dataset) – The dataset containing the data points.

  • params (Parameters) – The fitted parameters from lmfit.

  • nboot (int) – Number of bootstrap samples to generate confidence bands.

  • pp (PlotParameters | None) – Plotting parameters for consistent styling.

Return type:

None

clophfit.fitting.plotting.plot_fit_gemini(ax, ds, params, nboot=0, pp=None)#

Plot fitted curves and data points on a given axis.

Parameters:
  • ax (axes.Axes) – The matplotlib axis to plot on.

  • ds (Dataset) – The dataset containing the data points.

  • params (Parameters) – The fitted parameters from lmfit.

  • nboot (int) – Number of bootstrap samples to generate confidence bands.

  • pp (PlotParameters | None) – Plotting parameters for consistent styling.

Return type:

None

clophfit.fitting.plotting.print_emcee(result_emcee)#

Print maximum likelihood estimation (MLE) results from an emcee fitting.

Parameters:

result_emcee (lmfit.minimizer.MinimizerResult)

Return type:

None