Temas en R
Un tema es todo lo que no es dato: fuentes, cuadrículas, leyendas, márgenes.
library(ggplot2)
library(tibble)
runs <- tibble(day = 1:5, tpm = c(88, 92, 96, 99, 104))
plot <- ggplot(runs, aes(day, tpm)) +
geom_col(fill = "gray40") +
theme_minimal(base_size = 11) +
theme(
panel.grid.minor = element_blank(),
panel.grid.major.x = element_blank(),
axis.title = element_text(colour = "gray30"),
plot.title = element_text(face = "bold", size = 13),
legend.position = "none"
) +
labs(title = "Minimal, then adjusted")
print(inherits(plot$theme, "theme"))
ggsave(tempfile(fileext = ".png"), plot, width = 4, height = 3, dpi = 100)
Cómo funciona
- Un tema completo como
theme_minimalreemplaza los valores por defecto. theme()ajusta luego elementos individuales.theme_setaplica uno para toda la sesión.
El intento, en números
- Líneas
- 19
- Caracteres a escribir
- 549
- Tokens
- 149
- Ritmo de tres estrellas
- 105 tpm
Al ritmo de tres estrellas de 105 tokens por minuto, este intento toma unos 85 segundos.
Paso 2 de 3 en Rematar un gráfico; paso 13 de 15 en ggplot2.