heatmap.png
如上图所示,采用seaborn绘制热力图(关键代码sns.heatmap(df, cmap=cmap, linewidths=.00, annot=True)),heatmap的colorbar是自动生成的,不能用绘图的legend控制,当想要修改它的大小时,可以采用如下方法设置。
通过获取绘图面板的colorbar要素,单独进行label size设置,主要代码如下
# use matplotlib.colorbar.Colorbar object
cbar = ax.collections[0].colorbar
# here set the labelsize by 20
cbar.ax.tick_params(labelsize=20)
调整完如下:
heatmap_large.png
参考资料:https://stackoverflow.com/questions/37233108/seaborn-change-font-size-of-the-colorbar












网友评论