Temas personalizados de ggplot2

Comunicar con datos en el Tidyverse

Timo Grossenbacher

Data Journalist

Ventajas de un aspecto personalizado

Comunicar con datos en el Tidyverse

La función 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")
  )

Comunicar con datos en el Tidyverse

Temas predeterminados de ggplot2

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

  theme_classic()

Comunicar con datos en el Tidyverse

Encadenar llamadas 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")
  )

Comunicar con datos en el Tidyverse

Opciones de configuración del tema

?theme

axis.title
etiqueta de los ejes (element_text; hereda de text)

axis.title.x
etiqueta del eje x (element_text; hereda de axis.title)

axis.title.x.top
etiqueta del eje x en el eje superior (element_text; hereda de axis.title.x)

axis.title.x.bottom
etiqueta del eje x en el eje inferior (element_text; hereda de axis.title.x)

Comunicar con datos en el Tidyverse

La familia de funciones 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()
  )

Comunicar con datos en el Tidyverse

¡Vamos a probar temas!

Comunicar con datos en el Tidyverse

Preparing Video For Download...