小编Ben*_*Ben的帖子

将颜色条移近热图 (Seaborn)

我的颜色条距离热图底部很远。有办法让它靠近一点吗?

我的代码是:


import seaborn as sns

Granger2 = Granger
Granger2.columns = Granger_colnames
Granger2.index = Granger_rownames

fig, ax = plt.subplots(figsize=(6,25)) 
sns.heatmap(Granger2, cmap=rvb, cbar=True, ax=ax,linewidths=.5,cbar_kws={"orientation": "horizontal"})
ax.xaxis.tick_top() # x axis on top
ax.xaxis.set_label_position('top')

#Remove ticks
ax.tick_params(axis='both', which='both', length=0)

# Drawing the frame
ax.axhline(y = 0, color='k',linewidth = 1)
ax.axhline(y = Granger2.shape[0], color = 'k',linewidth = 1)  
ax.axvline(x = 0, color = 'k', linewidth = 1)
ax.axvline(x = Granger2.shape[1], color = 'k', linewidth = 1)

plt.show()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python data-visualization matplotlib heatmap seaborn

2
推荐指数
1
解决办法
2916
查看次数