correlation_matrix

correlation_matrix#

class braintools.visualize.correlation_matrix(data, labels=None, method='pearson', cmap='RdBu_r', mask_diagonal=False, show_values=True, value_format='.2f', ax=None, figsize=(10, 8), show_colorbar=True, title=None, **kwargs)#

Plot correlation matrix heatmap.

Parameters:
  • data (ndarray) – Data matrix of shape (samples, features).

  • labels (List[str] | None) – Feature labels.

  • method (str) – Correlation method: ‘pearson’, ‘spearman’, ‘kendall’.

  • cmap (str) – Colormap for the matrix.

  • mask_diagonal (bool) – Whether to mask the diagonal.

  • show_values (bool) – Whether to show correlation values.

  • value_format (str) – Format string for values.

  • ax (Axes | None) – Axes to plot on.

  • figsize (Tuple[float, float]) – Figure size if creating new figure.

  • show_colorbar (bool) – Whether to show colorbar.

  • title (str | None) – Plot title.

  • **kwargs – Additional arguments passed to imshow.

Returns:

ax – The axes object containing the plot.

Return type:

Axes