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

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

上一篇:sns.countplot用法


下一篇:继续用python给女朋友挑钻石(小提琴图和箱线图)