การสร้างภาพข้อมูลเชิงโต้ตอบด้วย plotly ใน R ระดับกลาง
Adam Loy
Statistician, Carleton College
Transient selection
การเลือกก่อนหน้าจะถูกลืม

Persistent selection
การเลือกจะสะสมต่อเนื่อง


shared_data <- world2014 %>% SharedData$new()
p1 <- shared_data %>%
plot_ly(x=~urban/population, y = ~co2, text = ~country) %>%
add_markers()
p2 <- shared_data %>%
plot_ly(x=~income, y = ~co2, text = ~country) %>%
add_markers()
subplot(p1, p2, titleX = TRUE, shareY = TRUE) %>%
hide_legend()
เปิดใช้ persistent selection ผ่าน highlight()
subplot(p1, p2, titleX = TRUE, shareY = TRUE) %>%
hide_legend() %>%
highlight(persistent = TRUE)


เพิ่ม dynamic = TRUE เพื่อเปิดใช้ตัวเลือกสี
subplot(p1, p2, titleX = TRUE, shareY = TRUE) %>%
hide_legend() %>%
highlight(persistent = TRUE, dynamic = TRUE)
Direct manipulation
เลือกโดยโต้ตอบกับองค์ประกอบในกราฟโดยตรง

Indirect manipulation
เลือกผ่านคิวรีที่อยู่นอกกราฟ


world_indicators %>%
SharedData$new(key = ~country) %>%
plot_ly(x = ~year, y = ~income, alpha = 0.5) %>%
group_by(country) %>%
add_lines()
world_indicators %>%
SharedData$new(key = ~country, group = "Select a country") %>%
plot_ly(x = ~year, y = ~income, alpha = 0.5) %>%
group_by(country) %>%
add_lines() %>%
highlight(selectize = TRUE)

การสร้างภาพข้อมูลเชิงโต้ตอบด้วย plotly ใน R ระดับกลาง