标签:mat dataset nbsp sci center lin style int lib
#!/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()
标签:mat dataset nbsp sci center lin style int lib
原文地址:https://www.cnblogs.com/lifengwu/p/9821737.html