Learn R Programming

bayesplot (version 1.2.0)

theme_default: Default plotting theme

Description

The theme_default function returns the default ggplot theme used by the bayesplot plotting functions. Many of the individual plotting functions also make small alterations to the default theme using the convenience functions documented at bayesplot-helpers. To use a different theme simply add that theme to the ggplot objects created by the bayesplot plotting functions (see Examples, below).

Usage

theme_default(base_size = getOption("bayesplot.base_size", 12),
  base_family = getOption("bayesplot.base_family", "serif"))

Arguments

base_size, base_family

Base font size and family (passed to theme_bw). It is possible to set "bayesplot.base_size" and "bayesplot.base_family" via options to change the defaults, which are 12 and "serif", respectively.

Value

A ggplot theme object.

See Also

bayesplot-helpers for a variety of convenience functions, many of which provide shortcuts for tweaking theme elements after creating a plot.

bayesplot-colors to set or view the color scheme used for plotting.

Examples

Run this code
# NOT RUN {
thm <- theme_default()
class(thm)
names(thm)

# plot using the default theme
x <- example_mcmc_draws()
mcmc_hist(x)

# change the default font size and family
options(bayesplot.base_size = 10,
        bayesplot.base_family = "sans")
mcmc_hist(x)
mcmc_areas(x, regex_pars = "beta")

# change back
options(bayesplot.base_size = 12,
        bayesplot.base_family = "serif")
mcmc_areas(x, regex_pars = "beta")

# use one of the themes included in ggplot2
mcmc_dens_overlay(x) + ggplot2::theme_gray()

# }

Run the code above in your browser using DataLab