Vizualizace aspektů dat pomocí fazet

Komunikace s daty v Tidyverse

Timo Grossenbacher

Data Journalist

Funkce 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))

Komunikace s daty v Tidyverse

Funkce 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))

Komunikace s daty v Tidyverse

Fazotový bodový graf

Komunikace s daty v Tidyverse

Stylování fazotových grafů

strip.background
strip.text
...

Komunikace s daty v Tidyverse

Definování vlastní funkce motivu

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()

Komunikace s daty v Tidyverse

Pojďme si procvičit!

Komunikace s daty v Tidyverse

Preparing Video For Download...