2021-03-21
閱讀量:
2826
為heatmap實現(xiàn)自定義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 #設(shè)置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)#設(shè)置colorbar刻度字體大小 cb.set_label('colorbar label') #設(shè)置colorbar的label plt.show()
效果圖






評論(0)


暫無數(shù)據(jù)
推薦帖子
0條評論
0條評論
0條評論
0條評論