These functions get, set, and modify the ggplot2 themes of the baggr plots. baggr_theme_get() returns a ggplot2 theme function for adding themes to a plot. baggr_theme_set() assigns a new theme for all plots of baggr objects. baggr_theme_update() edits a specific theme element for the current theme while holding the theme's other aspects constant. baggr_theme_replace() is used for wholesale replacing aspects of a plot's theme (see ggplot2::theme_get()).
The get method returns the current theme, but all of the others invisibly return the old theme.
Details
Under the hood, many of the visualizations rely on the bayesplot package, and thus these leverage the bayesplot::bayesplot_theme_get()
functions. By default, these match the bayesplot's package theme to make it easier to form cohesive graphs across this package and others. The trickiest of these to use is baggr_theme_replace; 9 times out of 10 you want baggr_theme_update.
Examples
# make plot look like default ggplotslibrary(ggplot2)fit <- baggr(schools)baggr_theme_set(theme_grey())baggr_plot(fit)# use baggr_theme_get to return theme elements for current themeqplot(mtcars$mpg)+ baggr_theme_get()# update specific aspect of theme you are interested inbaggr_theme_update(text = element_text(family ="mono"))# undo that sillinessbaggr_theme_update(text = element_text(family ="serif"))# update and replace are similar, but replace overwrites the# whole element, update just edits the aspect of the element# that you give it# this will error:# baggr_theme_replace(text = element_text(family = "Times"))# baggr_plot(fit)# because it deleted everything else to do with text elements