Creating a new ggplot2 theme

I had a similar reaction to yours, @igor , so I followed @Gabor's suggestion and posted a question on github:

The immediate response was a similar reaction by one of the maintainers:

Honestly, I'm a little surprised by this recommendation, or at least the wording of it. If you have a theme_custom() constructor, you wouldn't need a default_theme() wrapper.

I think the important bit to take away is that whenever you make a theme, always actually contruct it by running the contents through the theme() function. If you're making a package, don't save an already constructed theme to a variable or to disk, but have a function that builds the theme from stratch (or builds on a pre-existing theme).

So I expect the documentation you linked will be corrected soon, and in the meantime, you can find an alternative explanation of the do's and don't's in the reply to my post.

4 Likes