為 hoverinfo 加點內容
在影片課程中,你學到如何完整自訂 plotly 顯示的滑鼠暫留資訊(hover info)。這種做法很棒,但如果你只想快速加上一個識別用的欄位,而不是把圖表打磨到可以上網發佈呢?你可以在 plot_ly() 指令中加入 text 參數,且不需要指定 hoverinfo = "text"。
plotly 已為你載入。
本練習屬於課程
使用 R 的 plotly 互動式資料視覺化
練習說明
- 建立 2016 年銷售的電玩遊戲之使用者評分(
User_Score)對評論者評分(Critic_Score)的散佈圖,將Critic_Score放在 x 軸,User_Score放在 y 軸。 - 在
plot_ly()的圖層中,將遊戲名稱(Name)映射到text參數,讓它出現在滑鼠暫留資訊裡。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a scatterplot of User_Score vs. Critic score
vgsales2016 %>%
# Add video game Name to the hover info text
___ %>%
___