visualise_correlation_matrix#

visualise_correlation_matrix(correlation_matrix, categories, triangle_to_plot=None, colorbar_limit=None, center=0, ax=None, colorbar_label='Correlation', cmap='RdBu_r', figure_kwargs={})#

Visualise a correlation matrix using a heatmap.

Parameters:
correlation_matrixarray-like

The correlation matrix to be visualized.

categorieslist of str

The labels for the categories in the correlation matrix.

triangle_to_plotstr, optional

Specify ‘upper’ or ‘lower’ to plot only the upper or lower triangle of the correlation matrix. If None, the entire matrix is plotted. Default is None.

colorbar_limitlist of float, optional

The limits for the colorbar. If None, the limits are set to the maximum absolute value in the correlation matrix. Default is None.

centerfloat, optional

The value at which to center the colormap. Default is 0.

axmatplotlib.axes.Axes, optional

The axes on which to plot the heatmap. If None, a new figure and axes are created. Default is None.

colorbar_labelstr, optional

The label for the colorbar. Default is ‘Correlation’.

cmapstr, optional

The colormap to use for the heatmap. Default is ‘RdBu_r’.

figure_kwargsdict, optional

Additional keyword arguments to pass to plt.figure if a new figure is created. Default is {}.

Returns:
figmatplotlib.figure.Figure

The figure object containing the heatmap.

axmatplotlib.axes.Axes

The axes object containing the heatmap.

Raises:
ValueError

If triangle_to_plot is not ‘upper’, ‘lower’, or None.