I have a correlation matrix named corrdata
that I calculated using numpy.corrcoef
. Then what I do is extract one or a few rows of this matrix, and now just want to plot them instead of the whole matrix.
Because the matrix is no longer square, it is not possible to plot the data using pcolor
, imshow
, or the likes.
So I want to ask for the best alternative way to plot these extracted correlation coefficients and get the same appearance as the correlation matrix would in terms of coloured squares representing the value of the correlation coefficient, but only showing a few rows of the full matrix.
You can simply insert an extra singleton dimension in order to turn your
(n,)
1D vector into a(1, n)
2D array, then usepcolor
,imshow
etc. as normal:See here for some more ways to convert a 1D vector to a 2D array.