การกำหนดป้ายกำกับข้อมูล

การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

Adam Loy

Statistician, Carleton College

ภาพเคลื่อนไหว scatter plot แบบค่าเริ่มต้น

การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

ภาพเคลื่อนไหว bar chart แบบค่าเริ่มต้น

การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

ภาพเคลื่อนไหว box plot แบบค่าเริ่มต้น

การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

การเปลี่ยนค่าเริ่มต้น

 wine %>%
  count(Type) %>%  
  plot_ly(x = ~Type, y = ~n,
      # Changing the default info displayed
          hoverinfo = "y" 
  ) %>%
  add_bars()

hoverinfo =

  • "all"
  • "x"
  • "y"
  • "x+y"
  • "x+y+z"
การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

การกำหนด hover text เอง

wine %>%
  plot_ly(x = ~Flavanoids, y = ~Alcohol,

hoverinfo = "text",
text = ~paste("Flavanoids:", Flavanoids, "<br>", "Alcohol:", Alcohol)
) %>% add_markers()
  • ใช้ tilde ~ เพื่อ map คอลัมน์ไปยังพารามิเตอร์ aesthetic

การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

มาฝึกกันเถอะ!

การสร้างกราฟิกแบบโต้ตอบด้วย plotly ใน R

Preparing Video For Download...