2.1.7.4.Matrix Plots
0. Matrix Plots的繪圖種類
sns.heatmap
sns.clustermap
1. 使用library
import seaborn as sns
將圖表直接嵌入到Notebook之中
%matplotlib inline
讀入資料
tips = sns.load_dataset('tips')
tips.head()

flights = sns.load_dataset('flights')
flights.head()

2.heatmap (熱力圖)
視覺化矩陣形式中各行列的數值關係
視覺化歷史各年度中的各月份的航班密度
# 重新排列資料 fp = flights.pivot_table(index='month', columns='year', values='passengers')
sns.heatmap(fp)
改變熱力圖的色調及線條
sns.heatmap(fp, cmap='coolwarm', linecolor='blue', linewidth=1)
3.clustermap (階層式熱力圖)
sns.clustermap(fp)

正規化
sns.clustermap(fp, cmap='coolwarm', standard_scale=1)

Last updated
Was this helpful?