Python如何实现热力图
这篇文章将为大家详细讲解有关Python如何实现热力图,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
#导入库import seaborn as snsimport pandas as pdimport numpy as npimport matplotlib.pyplot as plt
data = np.random.random((6,6))
features = ["prop1","prop2","prop3","prop4","prop5","prop6"]data = pd.DataFrame(data,index = features,columns=features)heatmap_plot=sns.heatmap(data,center=0,cmap='gist_rainbow')
#导入库 import seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt #生成数据集 data = np.random.random((6,6)) features = ["prop1","prop2","prop3","prop4","prop5","prop6"] data = pd.DataFrame(data,index = features,columns=features) print(data) #绘制热力图 heatmap_plot=sns.heatmap(data,center=0,cmap='gist_rainbow') plt.show()
关于“Python如何实现热力图”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。