diff --git a/NAMESPACE b/NAMESPACE index 8d851e460..da1718143 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -61,6 +61,12 @@ export(purple) export(red) export(set_blanket) export(teal) +export(weave_col_palette_c) +export(weave_col_palette_d) +export(weave_col_palette_o) +export(weave_geom_defaults) +export(weave_mode) +export(weave_theme) importFrom(magrittr,"%>%") importFrom(rlang,"!!!") importFrom(rlang,"!!") diff --git a/NEWS.md b/NEWS.md index 9749522ed..3a4c3d84f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,9 +5,10 @@ * Breaking: removed `greyness` helper. * Breaking: removed `*_orientation` arguments from `*_mode_*` functions. * Breaking: In `set_blanket`, renamed `annotate_*` arguments to `annotation_*`. +* Added `*_symmetric` arguments. * Added `mode_orientation` argument. * Added `*_breaks_n` and `*_sec_axis` arguments. -* Added `*_symmetric` arguments. +* Added `weave_*` setup functions. * Added `mode_orientation_to_x` and `mode_orientation_to_y` functions. * In `set_blanket`, changed `theme` argument default to `theme_grey()`. diff --git a/R/weave.R b/R/weave.R index fe2bdad94..04746d1e5 100644 --- a/R/weave.R +++ b/R/weave.R @@ -16,7 +16,7 @@ ggblanket_global$theme <- NULL #' #' @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`. #' -#' @noRd +#' @export weave_mode <- function(mode = light_mode_r()) { old <- ggblanket_global$mode ggblanket_global$mode <- mode @@ -29,7 +29,7 @@ weave_mode <- function(mode = light_mode_r()) { #' #' @param theme A ggplot2 theme that the `gg_*` function will add without side-effects. Note, `mode` takes precedence, unless `mode = NULL`. #' -#' @noRd +#' @export weave_theme <- function(theme = light_mode_r() + mode_orientation_to_x()) { old <- ggblanket_global$theme ggblanket_global$theme <- theme @@ -48,7 +48,7 @@ weave_theme <- function(theme = light_mode_r() + mode_orientation_to_x()) { #' @param annotation_family A annotation_family for `*_text` and `*_label`. Defaults to "" #' @param annotation_size A annotation_size for `*_text` and `*_label`. Defaults to 3.88. #' -#' @noRd +#' @export weave_geom_defaults <- function(colour = "#357BA2FF", annotation_colour = "#121B24FF", annotation_linewidth = 0.33, @@ -101,7 +101,7 @@ weave_geom_defaults <- function(colour = "#357BA2FF", #' @param col_palette_d For a discrete scale, a character vector of hex codes (or col_palette_d_names) for the `col_palette_d`. #' @param col_palette_d_na For a discrete scale, a hex code (or col_palette_d_name) for the `col_palette_d_col_palette_d_na`. #' -#' @noRd +#' @export weave_col_palette_d <- function(col_palette_d = jumble, col_palette_d_na = "#CDC5BFFF") { if (rlang::is_null(col_palette_d_na)) col_palette_d_na <- "grey50" @@ -149,7 +149,7 @@ weave_col_palette_d <- function(col_palette_d = jumble, col_palette_d_na = "#CDC #' @param col_palette_c For a continuous scale, a character vector of hex codes (or col_palette_c_names) #' @param col_palette_c_na For a continuous scale, a hex code (or col_palette_c_name) for the `col_palette_col_palette_c_na`. #' -#' @noRd +#' @export weave_col_palette_c <- function(col_palette_c = viridisLite::mako(n = 9, direction = -1), col_palette_c_na = "#988F88FF") { # i.e. colorspace::darken(grey, 0.25) @@ -188,7 +188,7 @@ weave_col_palette_c <- function(col_palette_c = viridisLite::mako(n = 9, directi #' @param col_palette_o For an ordicol_palette_o_nal scale, a `scales::pal_*()` function for the `col_palette_o`. #' @param col_palette_o_na For an ordicol_palette_o_nal scale, a hex code (or col_palette_o_name) for the `col_palette_o_col_palette_o_na`. #' -#' @noRd +#' @export weave_col_palette_o <- function(col_palette_o = scales::pal_viridis(option = "G", direction = -1), col_palette_o_na = "#988F88FF") { diff --git a/_pkgdown.yml b/_pkgdown.yml index ed32a3860..fc654d0f0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -20,8 +20,17 @@ reference: - dark_mode_r - dark_mode_t - dark_mode_b -- title: Colour +- title: Other - contents: + - aes_contrast + - weave_mode + - weave_theme + - weave_geom_defaults + - weave_col_palette_d + - weave_col_palette_c + - weave_col_palette_o + - mode_orientation_to_x + - mode_orientation_to_y - blue - jumble - teal @@ -34,8 +43,3 @@ reference: - lightness - darkness - linewidthness -- title: Other -- contents: - - aes_contrast - - mode_orientation_to_x - - mode_orientation_to_y diff --git a/man/weave_col_palette_c.Rd b/man/weave_col_palette_c.Rd new file mode 100644 index 000000000..c790c7e3f --- /dev/null +++ b/man/weave_col_palette_c.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/weave.R +\name{weave_col_palette_c} +\alias{weave_col_palette_c} +\title{Set a continuous colour palette} +\usage{ +weave_col_palette_c( + col_palette_c = viridisLite::mako(n = 9, direction = -1), + col_palette_c_na = "#988F88FF" +) +} +\arguments{ +\item{col_palette_c}{For a continuous scale, a character vector of hex codes (or col_palette_c_names)} + +\item{col_palette_c_na}{For a continuous scale, a hex code (or col_palette_c_name) for the \code{col_palette_col_palette_c_na}.} +} +\description{ +Set a continuous colour palette +} diff --git a/man/weave_col_palette_d.Rd b/man/weave_col_palette_d.Rd new file mode 100644 index 000000000..4feb9a0bb --- /dev/null +++ b/man/weave_col_palette_d.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/weave.R +\name{weave_col_palette_d} +\alias{weave_col_palette_d} +\title{Set a discrete colour palette} +\usage{ +weave_col_palette_d(col_palette_d = jumble, col_palette_d_na = "#CDC5BFFF") +} +\arguments{ +\item{col_palette_d}{For a discrete scale, a character vector of hex codes (or col_palette_d_names) for the \code{col_palette_d}.} + +\item{col_palette_d_na}{For a discrete scale, a hex code (or col_palette_d_name) for the \code{col_palette_d_col_palette_d_na}.} +} +\description{ +Set a discrete colour palette +} diff --git a/man/weave_col_palette_o.Rd b/man/weave_col_palette_o.Rd new file mode 100644 index 000000000..7c542a4d4 --- /dev/null +++ b/man/weave_col_palette_o.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/weave.R +\name{weave_col_palette_o} +\alias{weave_col_palette_o} +\title{Set an ordinal colour palette} +\usage{ +weave_col_palette_o( + col_palette_o = scales::pal_viridis(option = "G", direction = -1), + col_palette_o_na = "#988F88FF" +) +} +\arguments{ +\item{col_palette_o}{For an ordicol_palette_o_nal scale, a \verb{scales::pal_*()} function for the \code{col_palette_o}.} + +\item{col_palette_o_na}{For an ordicol_palette_o_nal scale, a hex code (or col_palette_o_name) for the \code{col_palette_o_col_palette_o_na}.} +} +\description{ +Set an ordinal colour palette +} diff --git a/man/weave_geom_defaults.Rd b/man/weave_geom_defaults.Rd new file mode 100644 index 000000000..4a3b67b3f --- /dev/null +++ b/man/weave_geom_defaults.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/weave.R +\name{weave_geom_defaults} +\alias{weave_geom_defaults} +\title{Set a series of geom defaults} +\usage{ +weave_geom_defaults( + colour = "#357BA2FF", + annotation_colour = "#121B24FF", + annotation_linewidth = 0.33, + annotation_family = "", + annotation_size = 3.88 +) +} +\arguments{ +\item{colour}{A hex colour (and fill) for geoms other than \verb{*_hline}/\verb{*_vline}/\verb{*_abline} and \verb{*_curve}. Fill inherits from this colour. Defaults to \code{blue} (i.e. \verb{#357BA2FF}).} + +\item{annotation_colour}{A hex annotation_colour (and fill) for \verb{*_hline}/\verb{*_vline}/\verb{*_abline} and \verb{*_curve}. Defaults to "#121b24" (i.e. \code{lightness[1]}).} + +\item{annotation_linewidth}{A annotation_linewidth for \verb{*_hline}/\verb{*_vline}/\verb{*_abline} and \verb{*_curve}. Defaults to 0.33.} + +\item{annotation_family}{A annotation_family for \verb{*_text} and \verb{*_label}. Defaults to ""} + +\item{annotation_size}{A annotation_size for \verb{*_text} and \verb{*_label}. Defaults to 3.88.} +} +\description{ +Update all geom defaults. +} diff --git a/man/weave_mode.Rd b/man/weave_mode.Rd new file mode 100644 index 000000000..318bc64fc --- /dev/null +++ b/man/weave_mode.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/weave.R +\name{weave_mode} +\alias{weave_mode} +\title{Set a mode} +\usage{ +weave_mode(mode = light_mode_r()) +} +\arguments{ +\item{mode}{A ggplot2 theme (e.g. \code{\link[=light_mode_t]{light_mode_t()}} or \code{\link[=dark_mode_r]{dark_mode_r()}}) that anticipates \verb{gg_*} side-effects of removing relevant axis line/ticks and gridlines per the \code{mode_orientation}.} +} +\description{ +Set a mode for the mode argument in \verb{gg_*} functions. +} diff --git a/man/weave_theme.Rd b/man/weave_theme.Rd new file mode 100644 index 000000000..e9682f60b --- /dev/null +++ b/man/weave_theme.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/weave.R +\name{weave_theme} +\alias{weave_theme} +\title{Set a theme} +\usage{ +weave_theme(theme = light_mode_r() + mode_orientation_to_x()) +} +\arguments{ +\item{theme}{A ggplot2 theme that the \verb{gg_*} function will add without side-effects. Note, \code{mode} takes precedence, unless \code{mode = NULL}.} +} +\description{ +Set a theme to be \code{+}-ed on unmodified to \verb{gg_*} functions. Note, \code{mode} takes precedence unless NULL. +}