Skip to content

Commit

Permalink
Update set_blanket and weave"
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhodge931 committed Jul 4, 2024
1 parent 002dd2f commit bfc40df
Show file tree
Hide file tree
Showing 109 changed files with 736 additions and 742 deletions.
39 changes: 19 additions & 20 deletions R/set_blanket.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#'
#' @param ... Provided to force user argument naming etc.
#' @param mode A ggplot2 theme (e.g. [light_mode_t()] or [dark_mode_r()]) that anticipates `gg_*` side-effects of removing relevant axis line/ticks and gridlines per the `mode_orientation`.
#' @param geom_colour A hex colour (and fill) for most geoms. Fill inherits from this colour. Defaults to `blue` (i.e. `#357BA2FF`).
#' @param annotation_colour A hex colour (and fill) for other geoms commonly used for annotation (i.e. `*_hline`/`*_vline`/`*_abline` and `*_curve`). Defaults to "#121b24" (i.e. `lightness[1]`).
#' @param colour A hex colour (and fill) for most geoms. Fill inherits from this colour. Defaults to `blue` (i.e. `#357BA2FF`).
#' @param annotation_colour A hex colour (and fill) for `*_hline`/`*_vline`/`*_abline` and `*_curve`. Defaults to "#121b24" (i.e. `lightness[1]`).
#' @param annotation_linewidth A linewidth for `*_hline`/`*_vline`/`*_abline` and `*_curve`. Defaults to 0.33.
#' @param annotation_family A family for `*_text` and `*_label`. Defaults to "".
#' @param annotation_size A size for `*_text` and `*_label`. Defaults to 3.88.
Expand All @@ -28,7 +28,7 @@
#'
#' set_blanket(
#' mode = dark_mode_r(),
#' geom_colour = orange,
#' colour = orange,
#' annotation_colour = darkness[1],
#' )
#'
Expand All @@ -52,7 +52,7 @@
set_blanket <- function(
...,
mode = light_mode_r(),
geom_colour = "#357BA2FF",
colour = "#357BA2FF",
annotation_colour = "#121B24FF",
annotation_linewidth = 0.33,
annotation_family = "",
Expand All @@ -63,34 +63,33 @@ set_blanket <- function(
col_palette_na_c = "#988F88FF",
col_palette_o = scales::pal_viridis(option = "G", direction = -1),
col_palette_na_o = "#988F88FF",
theme = ggplot2::theme_grey()) {
theme = light_mode_r() + mode_orientation_to_x()) {

weave_mode(new = mode)
weave_mode(mode = mode)

weave_geom_defaults(colour = geom_colour)

weave_annotation_defaults(
colour = annotation_colour,
linewidth = annotation_linewidth,
size = annotation_size,
family = annotation_family
weave_geom_defaults(
colour = colour,
annotation_colour = annotation_colour,
annotation_linewidth = annotation_linewidth,
annotation_size = annotation_size,
annotation_family = annotation_family
)

weave_col_palette_d(
new = col_palette_d,
na = col_palette_na_d
col_palette_d = col_palette_d,
col_palette_d_na = col_palette_na_d
)

weave_col_palette_o(
new = col_palette_o,
na = col_palette_na_o
col_palette_o = col_palette_o,
col_palette_o_na = col_palette_na_o
)

weave_col_palette_c(
new = col_palette_c,
na = col_palette_na_c
col_palette_c = col_palette_c,
col_palette_c_na = col_palette_na_c
)

weave_theme(new = theme)
weave_theme(theme = theme)
}

44 changes: 44 additions & 0 deletions R/unweave.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' Unweave geom defaults
#'
#' @noRd
unweave_geom_defaults <- function() {
ggplot2::update_geom_defaults("area", NULL)
ggplot2::update_geom_defaults("bar", NULL)
ggplot2::update_geom_defaults("boxplot", NULL)
ggplot2::update_geom_defaults("col", NULL)
ggplot2::update_geom_defaults("contour", NULL)
ggplot2::update_geom_defaults("contour_filled", NULL)
ggplot2::update_geom_defaults("crossbar", NULL)
ggplot2::update_geom_defaults("density", NULL)
ggplot2::update_geom_defaults("density2d", NULL)
ggplot2::update_geom_defaults("density_2d_filled", NULL)
ggplot2::update_geom_defaults("errorbar", NULL)
ggplot2::update_geom_defaults("function", NULL)
ggplot2::update_geom_defaults("hex", NULL)
ggplot2::update_geom_defaults("line", NULL)
ggplot2::update_geom_defaults("linerange", NULL)
ggplot2::update_geom_defaults("path", NULL)
ggplot2::update_geom_defaults("point", NULL)
ggplot2::update_geom_defaults("pointrange", NULL)
ggplot2::update_geom_defaults("polygon", NULL)
ggplot2::update_geom_defaults("quantile", NULL)
ggplot2::update_geom_defaults("raster", NULL)
ggplot2::update_geom_defaults("rect", NULL)
ggplot2::update_geom_defaults("ribbon", NULL)
ggplot2::update_geom_defaults("rug", NULL)
ggplot2::update_geom_defaults("segment", NULL)
ggplot2::update_geom_defaults("sf", NULL)
ggplot2::update_geom_defaults("smooth", NULL)
ggplot2::update_geom_defaults("spoke", NULL)
ggplot2::update_geom_defaults("step", NULL)
ggplot2::update_geom_defaults("violin", NULL)
#to add and adjust once ggplot makes GeomBin2d
ggplot2::update_geom_defaults("tile", NULL)

ggplot2::update_geom_defaults("abline", NULL)
ggplot2::update_geom_defaults("hline", NULL)
ggplot2::update_geom_defaults("vline", NULL)
ggplot2::update_geom_defaults("curve", NULL)
ggplot2::update_geom_defaults("text", NULL)
ggplot2::update_geom_defaults("label", NULL)
}
Loading

0 comments on commit bfc40df

Please sign in to comment.