Me gustaría crear un nuevo tema para ggplot
basado en theme_bw()
.Copiando y modificando un tema predeterminado
me imagino los siguientes pasos son necesarios (en pseudocódigo):
- hacer una copia de theme_bw():
theme_new() <- theme_bw()
- modificar la copia:
theme_update(axis.title.x = theme_text(family = base_family, size = base_size, vjust = 0.5))
Algún consejo sobre cómo implementar esto será muy apreciado!
Editar: @Andrie, he modificado su respuesta para mis necesidades:
theme_new <- theme_set(theme_bw())
theme_new <- theme_update(axis.title.x = theme_text(family = base_family, size = base_size, vjust = 0.5))
Sin embargo, me sale el siguiente error:
ggplot(mtcars, aes(factor(cyl))) + geom_bar()
Error in match(gparname, names(gpars)) : object 'base_size' not found
Edit: 31/10/2017, respuesta proporcionada por @Andrie funciona bien. R versión 3.4.1, ggplot2_2.2.1
gracias, esto funcionó! Intenté esto antes, pero no me di cuenta de la parte 'base_size = base_size, base_family = base_family' y siempre recibí el error' Error in match (gparname, names (gpars)): object 'base_size' not found'. – donodarazao
nota: esto ahora es redundante con el nuevo sistema de subdivisión introducido en ggplot2 0.9. – baptiste
[Enlace que describe el nuevo sistema de temas y describe cómo modificarlo.] (Https://github.com/wch/ggplot2/wiki/New-theme-system) – Gregor