其他分享
首页 > 其他分享> > sns画热力图(仅做个人记录)

sns画热力图(仅做个人记录)

作者:互联网

import numpy as np
import pandas as pd

import matplotlib
matplotlib.use('agg') # use to avoid ploting in Pycharm 
import matplotlib.pyplot as plt # matplotlib.use('agg') must be infront of this line
import seaborn as sns

''' your code '''
dis = pd.DataFrame(dis,columns = ..., index = ...)
ig, ax = plt.subplots(figsize=(...,...))
sns.heatmap(dis, annot=True, vmax=...,vmin = ..., xticklabels= True, yticklabels= True, square=True, cmap="YlGnBu")  ## change the vmax/vmin according to your scale

ax.set_title("... distance ..", fontsize=15)
ax.set_ylabel('...', fontsize=12)
ax.set_xlabel('...', fontsize=12)  
# plt.show()
# plt.savefig(os.path.join(root_path, title_name + ".png"))  ## pdf or img

在这里插入图片描述

标签:...,plt,力图,matplotlib,sns,import,ax,True,画热
来源: https://blog.csdn.net/weixin_43301333/article/details/120654864