Say we have a matrix A of shape N x M, which can be viewed as a collection of N vectors of shape 1 x M. The code below gives us the correlation matrix of A:

1
A_corr = np.corrcoef(A) # shape: (N, N)

To visualize it, just use plt.matshow(A_corr).

If N is so large that the figure could not provide a clear insight, we might alternatively use histograms like this:

1
2
3
4
5
def corr_matrix_to_array(corr_mat):
N = corr_mat.shape[0]
return np.array([corr_mat[i][j] for i in range(1, N) for j in range(i + 1, N)])
plt.hist(corr_matrix_to_array(A_corr), bins=np.linspace(-1, 1, N_bins))