Skip to content

theme_update(text) fails due to NULL values #1489

Closed
@oneillkza

Description

@oneillkza

It's possible, using theme(), to set individual font elements inline with plotting, eg (adapted from ggplot documentation example):

df <- data.frame(gp = factor(rep(letters[1:3], each = 10)), y = rnorm(30))
ggplot(df, aes(x = gp, y = y)) + 
    geom_point() +
    theme(text=element_text(size=16))

However, when using theme_update to try to set this globally, it complains about NULL values in the text element.

theme_update(text=element_text(size=16))
ggplot(df, aes(x = gp, y = y)) + 
    geom_point()

results in

Error in FUN(X[[i]], ...) : 
  Theme element 'text' has NULL property: family, face, colour, hjust, vjust, angle, lineheight, margin, debug

I don't know if this is intended, but it seems strange that the behaviour of theme() and update_theme() is different, and it's frustrating that it isn't possible to set font size globally.

(This is with ggplot2_2.0.0.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions