petab_select.plot

Visualization routines for model selection.

Plotting methods generally take a PlotData object as input, which can be used to specify information used by multiple plotting methods.

Module Attributes

LABEL_FONTSIZE

The font size of axis labels.

TICK_LABEL_FONTSIZE

The font size of axis tick labels.

DEFAULT_NODE_COLOR

The default color of nodes in graph plots.

Functions

bar_criterion_vs_models(plot_data[, ax, ...])

Plot all calibrated models and their criterion value.

graph_history(plot_data[, ...])

Plot all calibrated models in the model space, as a directed graph.

graph_iteration_layers(plot_data[, ax, ...])

Graph the models of each iteration of model selection.

line_best_by_iteration(plot_data[, ax])

Plot the improvement in criterion across iterations.

scatter_criterion_vs_n_estimated(plot_data)

Plot criterion values against number of estimated parameters.

upset(plot_data)

Plot an UpSet plot of estimated parameters and criterion.

Classes

PlotData(models[, criterion, ...])

Manage data used in plots.

petab_select.plot.DEFAULT_NODE_COLOR = 'darkgrey'

The default color of nodes in graph plots.

petab_select.plot.LABEL_FONTSIZE = 16

The font size of axis labels.

class petab_select.plot.PlotData(models, criterion=None, relative_criterion=False, labels=None, parameter_labels=None, colors=None)[source]

Manage data used in plots.

models

The models.

criterion

The criterion.

labels

Model labels. Defaults to petab_select.Model.model_label or petab_select.Model.model_id or petab_select.Model.hash. Keys are model hashes, values are the labels.

relative_criterion

Whether to display relative criterion values.

parameter_labels

Labels for parameters. Keys are parameter IDs, values are labels. To use the parameterName column of your PEtab parameters table, provide petab_problem.parameter_df["parameterName"].to_dict().

colors

Colors for each model. Keys are model hashes, values are matplotlib color specifiers ( https://matplotlib.org/stable/users/explain/colors/colors.html ).

__init__(models, criterion=None, relative_criterion=False, labels=None, parameter_labels=None, colors=None)[source]
augment_labels(criterion=False, added_parameters=False, removed_parameters=False)[source]

Add information to the plotted model labels.

N.B.: this resets any previous augmentation.

Parameters:
  • criterion (bool) – Whether to include the criterion values.

  • added_parameters (bool) – Whether to include the added parameters, compared to the predecessor model.

  • removed_parameters (bool) – Whether to include the removed parameters, compared to the predecessor model.

Return type:

None

get_default_labels()[source]

Get default model labels.

Return type:

dict[ModelHash, str]

petab_select.plot.TICK_LABEL_FONTSIZE = 12

The font size of axis tick labels.

petab_select.plot.bar_criterion_vs_models(plot_data, ax=None, bar_kwargs=None)[source]

Plot all calibrated models and their criterion value.

Parameters:
  • plot_data (PlotData) – The plot data.

  • ax (Axes) – The axis to use for plotting.

  • bar_kwargs (dict[str, Any]) – Passed to the matplotlib ax.bar call.

Return type:

Axes

Returns:

The plot axes.

petab_select.plot.graph_history(plot_data, draw_networkx_kwargs=None, spring_layout_kwargs=None, ax=None)[source]

Plot all calibrated models in the model space, as a directed graph.

Parameters:
  • plot_data (PlotData) – The plot data.

  • draw_networkx_kwargs (dict[str, Any]) – Forwarded to networkx.draw_networkx.

  • spring_layout_kwargs (dict[str, Any]) – Forwarded to networkx.spring_layout.

  • ax (Axes) – The axis to use for plotting.

Return type:

Axes

Returns:

The plot axes.

petab_select.plot.graph_iteration_layers(plot_data, ax=None, draw_networkx_kwargs=None, colorbar_mappable=None)[source]

Graph the models of each iteration of model selection.

Parameters:
  • plot_data (PlotData) – The plot data.

  • ax (Axes) – The axis to use for plotting.

  • draw_networkx_kwargs (dict[str, Any] | None) – Passed to the networkx.draw_networkx call.

  • colorbar_mappable (_ScalarMappable) – Customize the colors. See documentation for the mappable argument of matplotlib.pyplot.colorbar.

Return type:

Axes

Returns:

The plot axes.

petab_select.plot.line_best_by_iteration(plot_data, ax=None)[source]

Plot the improvement in criterion across iterations.

Parameters:
  • plot_data (PlotData) – The plot data.

  • ax (Axes) – The axis to use for plotting.

Return type:

Axes

Returns:

The plot axes.

petab_select.plot.scatter_criterion_vs_n_estimated(plot_data, ax=None, scatter_kwargs=None, max_jitter=0.2)[source]

Plot criterion values against number of estimated parameters.

Parameters:
  • plot_data (PlotData) – The plot data.

  • ax (Axes) – The axis to use for plotting.

  • scatter_kwargs (dict[str, str]) – Forwarded to matplotlib.axes.Axes.scatter.

  • max_jitter (float) – Add noise to distinguish models with the same number of parameters and similar criterion values. This is a positive value that is the maximal difference to the original value.

Return type:

Axes

Returns:

The plot axes.

petab_select.plot.upset(plot_data)[source]

Plot an UpSet plot of estimated parameters and criterion.

Parameters:

plot_data (PlotData) – The plot data.

Return type:

dict[str, Axes | None]

Returns:

The plot axes (see documentation from the upsetplot package).