-
Notifications
You must be signed in to change notification settings - Fork 2.1k
theme_update(text) fails due to NULL values #1489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm having the same problem, though I'm updating the theme manually with my.theme = theme_grey() + theme(text=element_text(family='Roboto', size=30)) As with OP, the same modification on a |
Interestingly, as a work-around, the following does work: theme_set(theme_bw(base_size = 16))
ggplot(df, aes(x = gp, y = y)) +
geom_point() |
The base theme settings which are inherited by other settings need to be fully specified. Otherwise nothing gets inherited. |
I see. So the solution for actually updating a single element of an element of a theme is something like: theme_update(text=(theme_grey()+theme(text = element_text(family = "Times")))$text ) That's pretty ugly; I'd expect theme_update to pull the base theme settings from the theme being updated, rather than requiring them to all be specified. It's your package, though. |
@oneillkza there's probably a better way to do it than that, but I hardly ever use themes so I'm the wrong person to ask. |
Thanks Hadley, that's understandable. Hmm ... looking at the actual definition for theme_update <- function(...) {
# Make a call to theme, then add to theme
theme_set(theme_get() %+replace% theme(...))
} So for now the better way to update individual elements in a theme is to bypass theme_set(theme_get() + theme(text=element_text(size=16)))
theme_get()$text It'd be nice to have an update function that uses |
Or, rather, I'll make a pull request ;) |
@oneillkza , Can't you just use the |
It's possible, using
theme()
, to set individual font elements inline with plotting, eg (adapted from ggplot documentation example):However, when using theme_update to try to set this globally, it complains about
NULL
values in thetext
element.results in
I don't know if this is intended, but it seems strange that the behaviour of
theme()
andupdate_theme()
is different, and it's frustrating that it isn't possible to set font size globally.(This is with
ggplot2_2.0.0
.)The text was updated successfully, but these errors were encountered: