diff --git a/R/plot-theme.R b/R/plot-theme.R index a07e77f..be4a5e4 100644 --- a/R/plot-theme.R +++ b/R/plot-theme.R @@ -6,12 +6,22 @@ #' defined in the `⁠element tree`⁠ argument. [`Splicing`][rlang::splice] a list #' is also supported. #' @examples -#' plot_theme() +#' set.seed(123) +#' small_mat <- matrix(rnorm(81), nrow = 9) +#' ggheatmap(small_mat) + +#' plot_theme(plot.background = element_rect(fill = "red")) +#' +#' # `plot_theme()` serves as the default theme and will always be +#' # overridden by any `theme()` settings applied directly to the plot +#' ggheatmap(small_mat) + +#' theme(plot.background = element_rect(fill = "blue")) + +#' plot_theme(plot.background = element_rect(fill = "red")) +#' #' @importFrom ggplot2 theme #' @importFrom rlang inject #' @export plot_theme <- rlang::new_function( - # We utilize editor completion by listing all theme arguments here. + # We utilize editor completion by listing all `theme()` arguments here. # By placing `...` at the beginning, we can check if the first # following argument is a `theme()` object rather than individual theme # elements. diff --git a/man/plot_theme.Rd b/man/plot_theme.Rd index 9bb2c38..d9868f1 100644 --- a/man/plot_theme.Rd +++ b/man/plot_theme.Rd @@ -397,7 +397,17 @@ Learn more about setting these aesthetics in \code{vignette("ggplot2-specs")}. } \examples{ -plot_theme() +set.seed(123) +small_mat <- matrix(rnorm(81), nrow = 9) +ggheatmap(small_mat) + + plot_theme(plot.background = element_rect(fill = "red")) + +# `plot_theme()` serves as the default theme and will always be +# overridden by any `theme()` settings applied directly to the plot +ggheatmap(small_mat) + + theme(plot.background = element_rect(fill = "blue")) + + plot_theme(plot.background = element_rect(fill = "red")) + } \seealso{ \code{\link[ggplot2:+.gg]{+.gg()}} and \link[ggplot2]{\%+replace\%},