Skip to content

Make the bayesplot default theme optional? #87

@gavinsimpson

Description

@gavinsimpson

At the moment, from what I can tell having only had a brief look at the code, you are hard coding thebayesplot theme_default() ggplot theme when each plot is created. This makes it tedious to override by the user (they must add their own + theme_foo() layers to every plot they create). Further, from a previous Issue I understand this might not work in all cases in bayesplot as some plots are actually multiple plots arranged on the device.

Instead, you can use the theme_set() functionality of ggplot2 to set the default theme when the package is attached. The cowplot package, for example, uses this to set its default theme. This requires an .onAttach() function to be defined in the package R source somewhere with the following:

.onAttach <- function(libname, pkgname) {
  ggplot2::theme_set(bayesplot::theme_default())
}

All instances of + theme_default() would also need to be removed.

Doing this won't change the output from plots unless a user decides to change the theme used with by their own explicit call to theme_set() after bayesplot is loaded.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions