開始使用免費開始

熱度圖的替代作法

熱度圖有好幾種替代方案。最佳選擇其實取決於資料本身,以及你想用這份資料傳達的重點。若包含時間軸,最直覺的選擇就是折線圖。

本練習屬於課程

ggplot2 中級資料視覺化

檢視課程

動手互動練習

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

# The heat map we want to replace
# Don't remove, it's here to help you!
ggplot(barley, aes(x = year, y = variety, fill = yield)) +
  geom_tile() +
  facet_wrap( ~ site, ncol = 1) +
  scale_fill_gradientn(colors = brewer.pal(9, "Reds"))

# Using barley, plot yield vs. year, colored and grouped by variety
___ +
  # Add a line layer
  ___ +
  # Facet, wrapping by site, with 1 row
  facet_wrap( ~ site, nrow = 1)
編輯並執行程式碼