Visualizing the results¶
socca provides built-in plotting utilities accessible via fit.plot. These are specifically intended for visualizing the results of the fitting process, and thus require a completed fit object (see “Running the model inference”).
Comparison plot¶
Generate a side-by-side comparison of data, model, and residuals using APLpy:
>>> fit.plot.comparison(name='comparison_figure')
The comparison() method accepts several customization options:
Argument |
Description |
|---|---|
|
Output filename (without extension). If |
|
Model component(s) to include (see below) |
|
Output format (default: |
|
Figure scaling factors for width and height |
|
Output resolution in dots per inch |
|
Colormap specification (see below) |
|
Colormap for the data panel (default: |
|
Colormap for the model panel (default: |
|
Colormap for the residuals panel (default: |
|
Dictionary of gridspec options (spacing, margins) |
|
Additional arguments passed to |
The component argument allows comparing the data against specific model components only:
None(default): Include all model componentsInteger: Single component index (e.g.,
component=0for the first component)List of integers: Multiple component indices (e.g.,
component=[0, 2])String: Component name (e.g.,
component='comp_00')Component object: The component instance itself
>>> # Compare data against only the first component
>>> fit.plot.comparison(name='comparison_comp0', component=0)
Colormaps can be specified in multiple ways via the cmaps argument:
A single colormap name applied to all panels
A list/tuple of three colormaps
[data_cmap, model_cmap, residual_cmap]A dictionary with keys
'data','model', and'residuals'
>>> # Custom colormaps
>>> fit.plot.comparison(name='figure', cmaps={'data': 'viridis',
... 'model': 'viridis',
... 'residuals': 'coolwarm'})
Corner plot¶
Visualize the posterior distributions using the corner library:
>>> fit.plot.corner(name='corner_figure')
The corner() method provides several options for customizing the output:
Argument |
Description |
|---|---|
|
Output filename (without extension). If |
|
Output format (default: |
|
Components to include (see below) |
|
Range in sigma units around the median for axis limits (default: |
|
Custom axis ranges as array of |
|
Quantiles to display on 1D histograms (default: |
|
Number of histogram bins (default: |
|
Array of true values to overplot (if known) |
The sigma argument sets the axis limits based on the specified number of standard deviations around the median of each parameter. If set to None, the limits are set automatically to encompass the full range of the samples. If edges is provided, it overrides the sigma setting with explicit min/max ranges for each parameter.
The component argument allows selecting which model components to include in the corner plot:
None(default): Include all componentsInteger: Single component index (e.g.,
component=0for the first component)List of integers: Multiple component indices (e.g.,
component=[0, 2])String: Component name (e.g.,
component='comp_00')Component object: The component instance itself
>>> # Corner plot for only the first component
>>> fit.plot.corner(name='corner_comp0', component=[0])
>>>
>>> # Corner plot for specific components
>>> fit.plot.corner(name='corner_selected', component=[0, 2], sigma=5.0)
>>>
>>> # With known true values for validation
>>> fit.plot.corner(name='corner_truth', truths=[0.0, 0.0, 1e-3, 0.5, 1.0])
Any additional keyword arguments are passed directly to the underlying corner.corner() function, allowing full customization of the plot appearance.
See the “Getting started” guide for example outputs of these plotting functions.