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画热力图(仅做个人记录)
最新推荐文章于 2024-04-16 08:53:14 发布