clawdia.plotting#
Ad-hoc plotting functions for visualizing results.
This module includes a variety of plotting utilities designed to help visualize and interpret results during the development and debugging of the CLAWDIA pipeline.
While not essential for CLAWDIA’s core processing, these functions are useful for presenting and analyzing outcomes, such as confusion matrices, dictionary atoms, and spectrograms.
- clawdia.plotting.plot_confusion(cmat, ax=None, labels=None, mode='both', vmin=None, vmax=None, cmap='PaleBlues', **kwargs)[source]#
Plot a confusion matrix.
Plot a pre-computed confusion matrix cmat. Rows must contain true values, and columns predicted values. For example, in a binary classification case:
T P
Pred C1
Pred C2
True C1
TP
FN
True C2
FP
TN
Where:
TP (True Positives): Correctly predicted Class 1.
FN (False Negatives): Class 1 incorrectly predicted as Class 2.
FP (False Positives): Class 2 incorrectly predicted as Class 1.
TN (True Negatives): Correctly predicted Class 2.
- Parameters:
- cmatarray-like of shape (n_classes, n_classes)
The confusion matrix to plot.
- axmatplotlib.axes.Axes, optional
The axes on which to plot the matrix. If not given, a new figure and axes are created.
- labelslist of str, optional
The labels for the classes. If not given, the integers from 0 to n_classes-1 are used.
- mode{‘absolute’, ‘percent’, ‘both’}
The format of the annotations: absolute numbers, percentages, or both. Defaults to ‘both’.
- vminfloat, optional
The minimum value of the color scale.
- vmaxfloat, optional
The maximum value of the color scale.
- cmapFunction (matplotlib’s Colormap equivalent) | str
Defaults to “PaleBlue”, a custom modification of Matplotlib’s “Blues”.
- **kwargs
Additional keyword arguments are passed to matplotlib.pyplot.subplots.
- Returns:
- figmatplotlib.figure.Figure or None
The figure containing the plot, or None if ax was given.
- clawdia.plotting.plot_dictionary(array, c=None, ylim=None, **plot_kw)[source]#
Plot atoms from a dictionary in a squared matrix.
- Parameters:
- array2d-array
Dictionary matrix with shape (a, l).
- cint, optional
Number of atoms at each side of the squared matrix of plots; the total number of plotted atoms will be c ** 2. If not given, it is computed as int(np.sqrt(a)).
- **plot_kwoptional
Passed to pyplot.subplots().