Vlastní témata ggplot2

Komunikace s daty v Tidyverse

Timo Grossenbacher

Data Journalist

Výhody vlastního vzhledu

Komunikace s daty v Tidyverse

Funkce theme()

ggplot(plot_data) +
  geom_histogram(aes(
    x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +
  theme(
    text = element_text(
      family = "Bookman",
      color = "gray25")
  )

Komunikace s daty v Tidyverse

Výchozí témata ggplot2

ggplot(plot_data) +
  geom_histogram(aes(
    x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +

  theme_classic()

Komunikace s daty v Tidyverse

Řetězení volání theme()

ggplot(plot_data) +
  geom_histogram(aes(
    x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +

  theme_classic() +
  theme(
    text = element_text(
      family = "Bookman",
      color = "gray25")
  )

Komunikace s daty v Tidyverse

Možnosti konfigurace tématu

?theme

axis.title
popisek osy (element_text; dědí z text)

axis.title.x
popisek osy x (element_text; dědí z axis.title)

axis.title.x.top
popisek osy x nahoře (element_text; dědí z axis.title.x)

axis.title.x.bottom
popisek osy x dole (element_text; dědí z axis.title.x)

Komunikace s daty v Tidyverse

Rodina funkcí element_*

element_text()
element_rect()
element_line()
element_blank()
ggplot(plot_data) +
  geom_histogram(aes(
    x = working_hours)) +
  labs(x = "Working hours per week",
       y = "Number of countries") +
  theme(
    text = element_blank()
  )

Komunikace s daty v Tidyverse

Vyzkoušejte si témata!

Komunikace s daty v Tidyverse

Preparing Video For Download...