Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhodge931 committed Dec 17, 2024
1 parent 9528e8f commit 12bdd3b
Show file tree
Hide file tree
Showing 13 changed files with 494 additions and 497 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Removed `gg_ribbon`, `gg_boxplot`, `gg_crossbar` and `gg_smooth` alpha default to `NA`.
* Added `gg_ribbon_line`.
* Updated `*_mode_*` themes to default to `axis_line_linewidth = 0.25`.
* In `set_blanket`, removed `theme` argument - and updated `weave_theme` to apply `weave_mode(mode = NULL)`.

# ggblanket 11.0.0

Expand Down
4 changes: 3 additions & 1 deletion R/annotate_axis_line.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#' Replace a axis line with an annotated segment, so that geom features are behind the axis line.
#' Replace a axis line with an annotated segment
#'
#' @description Replace a axis line with an annotated segment, so that geom features are in front of it.
#'
#' @param axis The axis. Either "x" or "y"
#' @param x_position The position of the "x" axis, if applicable. Either "bottom" or "top".
Expand Down
12 changes: 4 additions & 8 deletions R/set_blanket.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Set a style
#' Set the style
#'
#' @description
#' Weave the style by setting:
#'
#' 1. the mode to be added with `gg_*()` side-effects
#' 1. the mode to be added by default
#' 2. the geom defaults (e.g. colour/fill), and text and reference line defaults
#' 3. the col_palettes for discrete, continuous and ordinal colour/fill scales
#' 4. a theme to be added _without_ `gg_*()` side-effects.
#'
#' Alternatively, use the `weave_*` functions to only apply a subset of these.
#' A `weave_theme` function is also provided to set a theme _without_ `gg_*` side-effects.
#' [ggplot2::update_geom_defaults()] can be used to further fine-tune geom defaults.
#'
#' @param ... Provided to force user argument naming etc.
Expand All @@ -26,7 +26,6 @@
#' @param col_palette_na_d For a discrete scale, a hex code.
#' @param col_palette_na_c For a continuous scale, a hex code.
#' @param col_palette_na_o For an ordinal scale, a hex code.
#' @param theme A ggplot2 theme that the `gg_*` function will add without side-effects if the mode is set/weaved to `NULL` (and also is applied to ggplot code outside of ggblanket).
#'
#' @return A globally set style.
#' @export
Expand Down Expand Up @@ -77,8 +76,7 @@ set_blanket <- function(
col_palette_o = scales::pal_viridis(option = "G", direction = -1),
col_palette_na_d = "#CDC5BFFF",
col_palette_na_c = "#988F88FF",
col_palette_na_o = "#988F88FF",
theme = light_mode_r() + mode_orientation_to_x()) {
col_palette_na_o = "#988F88FF") {

weave_mode(mode = mode)

Expand All @@ -100,7 +98,5 @@ set_blanket <- function(
col_palette_na_c = col_palette_na_c,
col_palette_na_o = col_palette_na_o
)

weave_theme(theme = theme)
}

9 changes: 6 additions & 3 deletions R/weave.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ weave_col_palette_o <- function(col_palette_o = scales::pal_viridis(option = "G"
invisible(old)
}

#' Set a theme (without side-effects)
#' Set a theme to apply _without_ side-effects
#'
#' @description Set a theme to be `+`-ed on unmodified to `gg_*` functions. Note, the `mode` takes precedence, unless the set/weaved mode is `mode = NULL`.
#' @description Set a theme to added to `gg_*` functions _without_ side-effects.
#' Note this sets the mode to NULL to allow this to work, and therefore should be run after `set_blanket`.
#'
#' @param theme A ggplot2 theme that the `gg_*` function will add without side-effects if the mode is set/weaved to `NULL` (and also is applied to ggplot code outside of ggblanket).
#' @param theme A ggplot2 theme that the `gg_*` function will add without side-effects.
#'
#' @export
weave_theme <- function(theme = light_mode_r() + mode_orientation_to_x()) {
weave_mode(mode = NULL)

old <- ggblanket_global$theme
ggblanket_global$theme <- theme
invisible(old)
Expand Down
4 changes: 2 additions & 2 deletions man/annotate_axis_line.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions man/set_blanket.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/weave_theme.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 12bdd3b

Please sign in to comment.