目录
绘制离散数据的热力图
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
# 创建一个随机的离散矩阵
data = np.random.randint(low=0, high=5, size=(10, 10))
# 绘制离散数据的热力图
sns.heatmap(data, annot=True, cmap='Set3', fmt='d')
plt.show()
绘制对称矩阵的热力图
import seaborn as sns
import matplotlib.pyplot as plt
# 创建一个随机对称矩阵
data = np.random.rand(10, 10)
symmetric_data = (data + data.T) / 2
# 绘制对称矩阵的热力图
sns.heatmap(symmetric_data, annot=True, cmap='YlGnBu')
plt.show()