Matplotlib热图非常小

Matplotlib热图非常小,matplotlib,random,python-3.6,heatmap,Matplotlib,Random,Python 3.6,Heatmap,我已经创建了一个热图,它将显示随机数数据集中所有列之间的相关性。热图创建得很好,但热图非常小,主要是在垂直方向。我在这篇帖子上贴了一张热图。数据集是来自csv文件的数据帧。代码如下所示: def colCorrelation(): xData = [] yData = [] fig, ax = plt.subplots(figsize=(5,5)) # calculates the correlation between all columns and all

我已经创建了一个热图,它将显示随机数数据集中所有列之间的相关性。热图创建得很好,但热图非常小,主要是在垂直方向。我在这篇帖子上贴了一张热图。数据集是来自csv文件的数据帧。代码如下所示:

def colCorrelation():
    xData = []
    yData = []

    fig, ax = plt.subplots(figsize=(5,5)) 
    # calculates the correlation between all columns and all other columns
    for i in range(0,100):
        for e in range(0,100):
            dataFlow = dict(zip([(i,e+1)], 
               [np.corrcoef(dfT[i],dfT[e+1])[0,1]]))
            if list(dataFlow.values())[0] < .9:
                xData.append(list(dataFlow.keys())[0][0])
                yData.append(list(dataFlow.values())[0])

    ## tuple of the two columns being correlated and their correlation
    ## in the dictionary as key value pairs data structure.
    ## Ex: {(19, 17): -0.015262993060948592}

    ## Plot heatmap
    heatmap, xedges, yedges = np.histogram2d(xData,yData,bins=(50))
    extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

    plt.clf()
    plt.title('Random Data heatmap')
    plt.ylabel('y')
    plt.xlabel('x')
    plt.imshow(heatmap,extent=extent)
    plt.show()

colCorrelation()
def colCorrelation():
扩展数据=[]
yData=[]
图,ax=plt.子批次(图尺寸=(5,5))
#计算所有列与所有其他列之间的相关性
对于范围(0100)内的i:
对于范围(0100)内的e:
数据流=dict(zip([(i,e+1)],
[np.corrcoef(dfT[i],dfT[e+1])[0,1]]
如果列表(dataFlow.values())[0]<.9:
扩展数据.append(列表(dataFlow.keys())[0][0])
追加(列表(dataFlow.values())[0])
##被关联的两列的元组及其相关性
##在字典中作为键值对的数据结构。
##例:{(19,17):-0.015262993060948592}
##绘制热图
热图,xedges,yedges=np.histogram2d(扩展数据,yData,bins=(50))
范围=[xedges[0],xedges[-1],yedges[0],yedges[-1]]
plt.clf()
plt.title(‘随机数据热图’)
plt.ylabel('y')
plt.xlabel('x')
plt.imshow(热图,范围=范围)
plt.show()
colCorrelation()

plt.imshow
中删除
extent
参数,因为它正在根据数据缩小绘图。

什么是
dfT
?此外,您还应该使用
ax.imshow
plt.subplot(…)
dfT是熊猫数据帧数据集的转置版本。打印
extent
时得到什么?打印extent时得到:[0.0,99.0,-0.7386211532854697,0.6795987850705433]从
imshow
中删除
范围
,因为它正在根据数据缩小绘图。