我可以想到两种使用numpy数组的选项。
Assuming your data is mostly higher than zero but there are a lot of zeros.:
vmin = some_value_higher_than_zero
plt.matshow(k,aspect='auto',vmin=vmin)
Setting all zeros to NaNs. they are automatically left out.
k[k==0.0]=np.nan
plt.matshow(k,aspect='auto')
注意:imshow和matshow在此处均可使用。
另一个选择是当您的矩阵非常稀疏时,可以使用散点图。
x,y = k.nonzero()
plt.scatter(x,y,s=100,c=k[x,y]) #color as the values in k matrix
.values
转换为浮点数,然后会自动转换为日期。(似乎输入参数x和y需要是相同的类型) - Worthy7