ファセットによるデータの可視化

Tidyverseによるデータコミュニケーション

Timo Grossenbacher

Data Journalist

facet_grid()関数

ilo_data <- ilo_data %>%
  filter(year == "1996" | year == "2006") 
ilo_plot <- ggplot(ilo_data) +
  geom_histogram(aes(
    x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries")

ilo_plot +
  facet_grid(cols = vars(year))
ilo_plot +
  facet_grid(rows = vars(year))

Tidyverseによるデータコミュニケーション

facet_grid()関数

ilo_data <- ilo_data %>%
  filter(year == "1996" | year == "2006")
ggplot(ilo_data) +
  geom_histogram(aes(x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +
  facet_grid(cols = vars(year))

ggplot(ilo_data) +
  geom_histogram(aes(x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +
  facet_wrap(facets = vars(year))

Tidyverseによるデータコミュニケーション

ファセット付き散布図

Tidyverseによるデータコミュニケーション

ファセットプロットのスタイル設定

strip.background
strip.text
...

Tidyverseによるデータコミュニケーション

独自テーマ関数の定義

theme_green <- function(){
  theme(
    plot.background = 
      element_rect(fill = "green"),
    panel.background = 
      element_rect(fill = 
        "lightgreen")
  )}
ggplot(ilo_data) +
  geom_histogram(aes(
    x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +

theme_green()

Tidyverseによるデータコミュニケーション

練習しましょう!

Tidyverseによるデータコミュニケーション

Preparing Video For Download...