開始使用免費開始

自訂熱圖

Seaborn 提供多種進階自訂方式,能讓熱圖的呈現更好看也更易讀。在這個練習中,我們會繼續使用儲存在變數 df 裡的 Daily Show 資料,但會著重在調整輸出效果。

本練習屬於課程

Seaborn 資料視覺化中級

檢視課程

練習說明

  • 建立 GroupYEAR 的交叉表
  • 使用 BuGn 配色方案繪製熱圖
  • 停用 cbar,並將 linewidth 增加到 0.3

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Create the crosstab DataFrame
pd_crosstab = pd.crosstab(df["Group"], df["____"])

# Plot a heatmap of the table with no color bar and using the BuGn palette
sns.heatmap(pd_crosstab, cbar=____, cmap="____", linewidths=____)

# Rotate tick marks for visibility
plt.yticks(rotation=0)
plt.xticks(rotation=90)

#Show the plot
plt.show()
plt.clf()
編輯並執行程式碼