heatmap热度图

Posted lifengwu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了heatmap热度图相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import numpy as np
import pandas as pd
import seaborn as sns
from scipy import stats
import matplotlib as mpl
import matplotlib.pyplot as plt
#热度图heatmap
np.random.seed(0)
sns.set()
uniform_data = np.random.rand(3,3)
print(uniform_data)
#vmin=0.3,vmax=0.6,指定最小值和最大值,center可以指定中间值
heatmap = sns.heatmap(uniform_data,vmin=0.3,vmax=0.6)
plt.show()
#读一份数据
flights = sns.load_dataset("flights")
print(flights.head())
flights = flights.pivot("month","year","passengers")
print(flights) #一个矩阵,乘客人数越来越多
ax = sns.heatmap(flights)

#annot=True表示把数字添加进图里,fmt="d":是一种格式,如果没有会有乱码
# linewidths:格子之间有间距
ax = sns.heatmap(flights,annot=True,fmt="d",linewidths=.5)
plt.show()
#,cmap:调色板
bx = sns.heatmap(flights,cmap="YlGnBu")
plt.show()

 

以上是关于heatmap热度图的主要内容,如果未能解决你的问题,请参考以下文章

对于百度地图新推出的热力图,国内外是不是有其他类似的产品

Python使用matplotlib可视化相关性分析热力图图heatmap使用seaborn中的heatmap函数可视化相关性热力图(Correllogram)

热图(heatmap)介绍

难以定位heatmap.2组件

mapreduce 中的map和reduce分别啥意思

用R中pheatmap画heatmap