選択の戦略

R で学ぶ中級インタラクティブ可視化(plotly)

Adam Loy

Statistician, Carleton College

2つの選択戦略

一時的な選択

前に選んだケースは保持されない

linking_teaser1.gif

永続的な選択

選択が蓄積される

linking_teaser2.gif

R で学ぶ中級インタラクティブ可視化(plotly)

before_persistent_selection.png

R で学ぶ中級インタラクティブ可視化(plotly)

ベースチャートの作成

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()
R で学ぶ中級インタラクティブ可視化(plotly)

永続的な選択

highlight() で永続的な選択を有効化

subplot(p1, p2, titleX = TRUE, shareY = TRUE) %>% 
  hide_legend() %>%
  highlight(persistent = TRUE)

persistent_selection.gif

R で学ぶ中級インタラクティブ可視化(plotly)

色でハイライト

dynamic_selection.gif

R で学ぶ中級インタラクティブ可視化(plotly)

色でハイライト

カラー ピッカーを有効にするには dynamic = TRUE を追加

subplot(p1, p2, titleX = TRUE, shareY = TRUE) %>% 
  hide_legend() %>%
  highlight(persistent = TRUE, dynamic = TRUE)
R で学ぶ中級インタラクティブ可視化(plotly)

2つの操作タイプ

直接操作

グラフ要素との対話で選択

linking_teaser1.gif

間接操作

チャート外のクエリで選択

indirect_manipulation.gif

R で学ぶ中級インタラクティブ可視化(plotly)

select_time_series.gif

R で学ぶ中級インタラクティブ可視化(plotly)

間接操作

world_indicators %>%
  SharedData$new(key = ~country) %>% 
  plot_ly(x = ~year, y = ~income, alpha = 0.5) %>%
  group_by(country) %>%
  add_lines()
R で学ぶ中級インタラクティブ可視化(plotly)

間接操作

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)
R で学ぶ中級インタラクティブ可視化(plotly)

indirect_manipulation.gif

R で学ぶ中級インタラクティブ可視化(plotly)

練習しましょう!

R で学ぶ中級インタラクティブ可視化(plotly)

Preparing Video For Download...