Niestandardowe motywy ggplot2

Komunikacja danych w Tidyverse

Timo Grossenbacher

Data Journalist

Zalety niestandardowego wyglądu

Komunikacja danych w Tidyverse

Funkcja 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")
  )

Komunikacja danych w Tidyverse

Domyślne motywy ggplot2

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

  theme_classic()

Komunikacja danych w Tidyverse

Łączenie wywołań 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")
  )

Komunikacja danych w Tidyverse

Opcje konfiguracji motywu

?theme

axis.title
etykieta osi (element_text; dziedziczy po text)

axis.title.x
etykieta osi x (element_text; dziedziczy po axis.title)

axis.title.x.top
etykieta osi x na górze (element_text; dziedziczy po axis.title.x)

axis.title.x.bottom
etykieta osi x na dole (element_text; dziedziczy po axis.title.x)

Komunikacja danych w Tidyverse

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

Komunikacja danych w Tidyverse

Czas wypróbować motywy!

Komunikacja danych w Tidyverse

Preparing Video For Download...