2021-03-21
阅读量:
2706
为heatmap实现自定义colorbar
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt data=pd.read_excel(r'C:\Users\34428\Desktop\test.xlsx') h=sns.heatmap(data=data.corr() ,cmap ='YlGnBu' ,cbar=False #设置cbar=False,删除seaborn中默认的colorbar ,annot=True ,vmin=0 ,vmax=1) #自定义colorbar cb = h.figure.colorbar(h.collections[0]) #显示colorbar cb.ax.tick_params(labelsize=10)#设置colorbar刻度字体大小 cb.set_label('colorbar label') #设置colorbar的label plt.show()
效果图






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论