開始使用免費開始

加入核取方塊

加入核取方塊篩選器,可以快速「點名」某個群組或一組群組,特別適合用來探索不同群組之間關聯如何改變。

在這個練習中,你的任務是為 2017 年的散佈圖加入區域(region)的核取方塊篩選器。該散佈圖呈現房價指數相對於自有住宅率的關係。

plotlycrosstalk 已為你載入,資料存於 us2017

本練習屬於課程

R 的 plotly 互動式資料視覺化:中級

檢視課程

練習說明

  • 在儲存在 p17 的散佈圖左側,加入 region 的核取方塊篩選器。
  • 將核取方塊的寬度限制為 3 欄,並讓圖表橫跨其餘欄位。

動手互動練習

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

# shared data object
shared_us <- SharedData$new(us2017, key = ~region)

# scatterplot of housing price index against homeownership
p17 <- shared_us %>%
  plot_ly(x = ~home_owners, y = ~house_price, color = ~region, height = 400) %>%
  add_markers()
  
# add a column of checkboxes for region to the left of the plot
___(___,
  ___(id = "region", label = "Region", sharedData = ___, group = ___),
  p17
)
編輯並執行程式碼