import random from matplotlib import pyplot as plt # 定义热图的横纵坐标 xLabel = ['A', 'B', 'C'] yLabel = ['1', '2', '3'] # 利用random生成伪数据(5*5) data = [] for i in range(3): temp = [] for j in range(3): k = random.randint(0, 100) temp.append(k) data.append(temp) fig = plt.figure() ax = fig.add_subplot(111) ax.set_yticks(range(len(yLabel))) ax.set_yticklabels(yLabel) ax.set_xticks(range(len(xLabel))) ax.set_xticklabels(xLabel) im = ax.imshow(data, cmap=plt.cm.hot_r) plt.colorbar(im) plt.title("test") plt.show()
这种图?
类似这种
撒打算的
作一个能反应损伤程度的热图
没人会就关闭了