%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np;
np.random.seed(0)
import seaborn as sns;
sns.set()
seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False, annot=None, fmt='.2g', annotkws=None, linewidths=0, linecolor='white', cbar=True, cbarkws=None, cbar_ax=None, square=False, ax=None, xticklabels=True, yticklabels=True, mask=None, **kwargs)
uniform_data = np.random.rand(3, 3) #生成数据
print (uniform_data)
heatmap = sns.heatmap(uniform_data) # 生成热力图
[[ 0.64272796 0.0229858 0.21897478]
[ 0.41076627 0.28860677 0.94805105]
[ 0.96513582 0.57781451 0.96400349]]
# 改变颜色映射的值范围
ax = sns.heatmap(uniform_data, vmin=0.2, vmax=1)
#为以0为中心的数据绘制一张热图
ax = sns.heatmap(uniform_data, center=0)
flights = sns.load_dataset("flights") #加载航班数据集
flights.head() #显示部分数据
flights = flights.pivot("month", "year", "passengers") #修改数据排列
flights.head()
ax = sns.heatmap(flights) #绘制热图
ax = sns.heatmap(flights, annot=True,fmt="d") #在heatmap中每个方格写入数据,按照整数形式
ax = sns.heatmap(flights, linewidths=.5) #热力图矩阵之间的间隔大小
ax = sns.heatmap(flights, cmap="YlGnBu") #修改热图颜色
ax = sns.heatmap(flights, cbar=False) #不显示热图图例
[Style functions]http://seaborn.pydata.org/tutorial/aesthetics.html#aesthetics-tutorial
[Color palettes]http://seaborn.pydata.org/tutorial/color_palettes.html#palette-tutorial
[Distribution plots]http://seaborn.pydata.org/tutorial/distributions.html#distribution-tutorial
[Categorical plots]http://seaborn.pydata.org/tutorial/categorical.html#categorical-tutorial
[Regression plots]http://seaborn.pydata.org/tutorial/regression.html#regression-tutorial
[Axis grid objects]http://seaborn.pydata.org/tutorial/axis_grids.html#grid-tutorial [10分钟python图表绘制]https://zhuanlan.zhihu.com/p/24464836