Oct-12-2021, 09:18 AM
I have a huge correlation matrix with the dimension of (654345,2,2). It was generated by Pearson's coefficients, i.e. numpy.corrcoef. What is the best way
of visualizing it? Below is a small part of the entire code;
of visualizing it? Below is a small part of the entire code;
def __init__(self): self.LayerIdx = ['CA3', 'DG', 'EC'] # propagation order def get_correlation(self, Layers, LayersPos): corr_xy = [] for layers_count in range(self.LayerNo - 1): x1 = Layers[layers_count] x2 = Layers[layers_count + 1] y1 = LayersPos[layers_count] y2 = LayersPos[layers_count + 1] for ind1 in range(len(y1)): for ind2 in range(len(y2)): corr_xy.append(np.corrcoef(x1[y1[ind1]], x2[y2[ind2]])) x_labels = [v for v in self.LayerIdx] y_labels = [v for v in self.LayerIdx] x_to_num = {p[1]: p[0] for p in enumerate(x_labels)} y_to_num = {p[1]: p[0] for p in enumerate(y_labels)} fig, ax = plt.subplots(figsize=(10, 6)) fig.subplots_adjust(left=0.0625, right=0.95, wspace=0.1) for i in range(np.shape(corr_xy)[0]): #corr_xy is the collection of Pearsons coefficients sns.heatmap(corr_xy[i], annot=True, fmt='.2f') ax.grid(False) ax.set_xticks([x_to_num[v] for v in x_labels]) # [x_to_num[v] for v in x_labels] ax.set_yticks([y_to_num[v] for v in y_labels]) cbar = ax.figure.colorbar(im, ax=ax, format='% .2f') plt.show()