Temi personalizzati di ggplot2

Comunicare con i dati nel Tidyverse

Timo Grossenbacher

Data Journalist

I vantaggi di uno stile personalizzato

Comunicare con i dati nel Tidyverse

La funzione 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")
  )

Comunicare con i dati nel Tidyverse

Temi predefiniti di ggplot2

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

  theme_classic()

Comunicare con i dati nel Tidyverse

Collegare più chiamate 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")
  )

Comunicare con i dati nel Tidyverse

Opzioni di configurazione del tema

?theme

axis.title
etichetta degli assi (element_text; eredita da text)

axis.title.x
etichetta asse x (element_text; eredita da axis.title)

axis.title.x.top
etichetta asse x sull'asse superiore (element_text; eredita da axis.title.x)

axis.title.x.bottom
etichetta asse x sull'asse inferiore (element_text; eredita da axis.title.x)

Comunicare con i dati nel Tidyverse

La famiglia di funzioni 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()
  )

Comunicare con i dati nel Tidyverse

Proviamo i temi!

Comunicare con i dati nel Tidyverse

Preparing Video For Download...