From 7c75df38f7be114595aaa2d5304a2a1eaefe9733 Mon Sep 17 00:00:00 2001 From: davidhodge931 Date: Fri, 13 Dec 2024 14:39:39 +1300 Subject: [PATCH] Update --- NEWS.md | 2 + R/gg_col_errorbar.R | 216 ++++++++++++++++++ R/gg_label.R | 25 +- R/gg_text.R | 25 +- R/set_blanket.R | 59 +++-- R/weave.R | 57 +++-- man/gg_label.Rd | 1 - man/gg_text.Rd | 1 - man/set_blanket.Rd | 49 ++-- man/weave_geom_defaults.Rd | 46 ++-- .../_snaps/article-demo-light/gg-label.svg | 67 +++--- .../_snaps/article-demo-light/gg-text.svg | 61 ++--- .../{lineribbon => ribbon-line}/datetime.svg | 0 tests/testthat/_snaps/set_blanket/1.svg | 2 +- tests/testthat/_snaps/set_blanket/2.svg | 2 +- tests/testthat/test-article-demo-light.R | 2 - tests/testthat/test-set_blanket.R | 12 +- vignettes/articles/1_demo_light.Rmd | 2 - vignettes/articles/2_demo_dark.Rmd | 7 +- vignettes/ggblanket.Rmd | 5 +- 20 files changed, 445 insertions(+), 196 deletions(-) create mode 100644 R/gg_col_errorbar.R rename tests/testthat/_snaps/{lineribbon => ribbon-line}/datetime.svg (100%) diff --git a/NEWS.md b/NEWS.md index f44e3f38f..fc76c1a6b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,11 +1,13 @@ # ggblanket 11.0.0.9000 +* Rethought `set_blanket` and `weave_geom_defaults` arguments. * Added R 4.2.0 dependency. * Removed `aes_colour_darken`, `aes_colour_lighten`, `aes_fill_darken` and `aes_colour_lighten`. * Removed `gg_ribbon`, `gg_boxplot`, `gg_crossbar` and `gg_smooth` alpha default to `NA`. * Added colour blending (e.g. `blend = "multiply`). * Added `gg_ribbon_line`. * Updated `*_mode_*` themes to default to `axis_line_linewidth = 0.25`. +* From `set_blanket`, removed `reference_*` arguments and replaced with `hline_*` and `vline_*` arguments. # ggblanket 11.0.0 diff --git a/R/gg_col_errorbar.R b/R/gg_col_errorbar.R new file mode 100644 index 000000000..c34359581 --- /dev/null +++ b/R/gg_col_errorbar.R @@ -0,0 +1,216 @@ +#' #' Lineribbon ggplot +#' #' +#' #' @description Create a lineribbon ggplot with a wrapper around [ggplot2::ggplot()] + [geom_ribbon()][ggplot2::geom_ribbon()] + [geom_line()][ggplot2::geom_line()] +#' #' +#' #' @inheritParams gg_blanket +#' #' +#' #' @return A ggplot object. +#' #' @export +#' #' +#' #' @examples +#' #' library(ggplot2) +#' #' library(dplyr) +#' #' +#' #' set_blanket() +#' #' +#' #' data.frame(year = 1875:1972, level = as.vector(LakeHuron)) |> +#' #' mutate(level_min = level - 1, level_max = level + 1) |> +#' #' gg_ribbon_line( +#' #' x = year, +#' #' y = level, +#' #' ymin = level_min, +#' #' ymax = level_max, +#' #' x_labels = \(x) x, +#' #' blend = "multiply", +#' #' ) +#' #' +#' gg_col_errorbar <- function(data = NULL, +#' ..., +#' stat = "identity", +#' position = "identity", +#' coord = ggplot2::coord_cartesian(clip = "off"), +#' mode = NULL, mode_orientation = NULL, blend = NULL, +#' x = NULL, +#' xmin = NULL, +#' xmax = NULL, +#' xend = NULL, +#' y = NULL, +#' ymin = NULL, +#' ymax = NULL, +#' yend = NULL, +#' z = NULL, +#' col = NULL, +#' facet = NULL, +#' facet2 = NULL, +#' group = NULL, +#' subgroup = NULL, +#' label = NULL, +#' text = NULL, +#' sample = NULL, +#' mapping = NULL, +#' x_breaks = NULL, x_breaks_n = NULL, +#' x_expand = NULL, +#' x_expand_limits = NULL, +#' x_label = NULL, x_labels = NULL, +#' +#' +#' x_position = "bottom", +#' +#' x_sec_axis = ggplot2::waiver(), x_symmetric = NULL, x_transform = NULL, +#' y_breaks = NULL, y_breaks_n = NULL, +#' y_expand = NULL, +#' y_expand_limits = NULL, +#' y_label = NULL, y_labels = NULL, +#' y_position = "left", +#' y_sec_axis = ggplot2::waiver(), +#' y_symmetric = NULL, +#' +#' y_transform = NULL, +#' col_breaks = NULL, col_breaks_n = 5, +#' col_drop = FALSE, +#' col_expand_limits = NULL, +#' col_label = NULL, col_labels = NULL, +#' col_legend_ncol = NULL, +#' col_legend_nrow = NULL, +#' col_legend_rev = FALSE, +#' +#' +#' col_palette = NULL, +#' col_palette_na = NULL, +#' col_rescale = scales::rescale(), +#' col_steps = FALSE, +#' +#' col_transform = NULL, +#' facet_axes = NULL, +#' facet_axis_labels = "margins", +#' facet_drop = FALSE, +#' facet_labels = NULL, +#' facet_layout = NULL, +#' facet_ncol = NULL, +#' facet_nrow = NULL, +#' facet_scales = "fixed", +#' facet_space = "fixed", +#' title = NULL, +#' subtitle = NULL, +#' caption = NULL, +#' label_to_case = snakecase::to_sentence_case) { +#' plot <- gg_blanket( +#' data = data, +#' geom = "blank", +#' stat = stat, +#' position = position, +#' coord = coord, +#' mode = mode, mode_orientation = mode_orientation, blend = blend, +#' x = {{ x }}, +#' y = {{ y }}, +#' xmin = {{ xmin }}, +#' xmax = {{ xmax }}, +#' xend = {{ xend }}, +#' ymin = {{ ymin }}, +#' ymax = {{ ymax }}, +#' yend = {{ yend }}, +#' z = {{ z }}, +#' col = {{ col }}, +#' facet = {{ facet }}, +#' facet2 = {{ facet2 }}, +#' group = {{ group }}, +#' subgroup = {{ subgroup }}, +#' label = {{ label }}, +#' text = {{ text }}, +#' sample = {{ sample }}, +#' mapping = mapping, +#' x_breaks = x_breaks, +#' x_expand = x_expand, +#' x_expand_limits = x_expand_limits, +#' x_labels = x_labels, +#' x_breaks_n = x_breaks_n, +#' x_sec_axis = x_sec_axis, +#' x_symmetric = x_symmetric, x_position = x_position, +#' x_label = x_label, +#' x_transform = x_transform, +#' y_breaks = y_breaks, +#' y_expand = y_expand, +#' y_expand_limits = y_expand_limits, +#' y_labels = y_labels, +#' y_breaks_n = y_breaks_n, +#' y_sec_axis = y_sec_axis, +#' y_symmetric = y_symmetric, y_position = y_position, +#' y_label = y_label, +#' y_transform = y_transform, +#' col_breaks = col_breaks, +#' col_drop = col_drop, +#' col_expand_limits = col_expand_limits, +#' col_labels = col_labels, +#' col_legend_ncol = col_legend_ncol, +#' col_legend_nrow = col_legend_nrow, +#' col_legend_rev = col_legend_rev, +#' col_breaks_n = col_breaks_n, +#' +#' col_palette = col_palette, +#' col_palette_na = col_palette_na, +#' col_rescale = col_rescale, +#' col_steps = col_steps, +#' col_label = col_label, +#' col_transform = col_transform, +#' facet_axes = facet_axes, +#' facet_axis_labels = facet_axis_labels, +#' facet_drop = facet_drop, +#' facet_labels = facet_labels, +#' facet_layout = facet_layout, +#' facet_ncol = facet_ncol, +#' facet_nrow = facet_nrow, +#' facet_scales = facet_scales, +#' facet_space = facet_space, +#' title = title, +#' subtitle = subtitle, +#' caption = caption, +#' label_to_case = label_to_case, +#' ... +#' ) +#' +#' if (rlang::is_null(blend)) { +#' plot + +#' list( +#' ggplot2::layer( +#' geom = "bar", +#' stat = stat, +#' position = position, +#' mapping = ggplot2::aes(!!!mapping), +#' params = rlang::list2(...), +#' # show.legend = show_legend, +#' ), +#' ggplot2::layer( +#' geom = "errorbar", +#' stat = stat, +#' position = position, +#' mapping = ggplot2::aes(!!!mapping), +#' params = rlang::list2(...), +#' # show.legend = show_legend, +#' ) +#' ) +#' } +#' else { +#' plot + +#' ggblend::blend( +#' list( +#' ggplot2::layer( +#' geom = "bar", +#' stat = stat, +#' position = position, +#' mapping = ggplot2::aes(!!!mapping), +#' params = rlang::list2(...), +#' # show.legend = show_legend, +#' ) |> ggblend::blend(blend = blend), +#' ggplot2::layer( +#' geom = "errorbar", +#' stat = stat, +#' position = position, +#' mapping = ggplot2::aes(!!!mapping), +#' params = rlang::list2(...), +#' # show.legend = show_legend, +#' ) |> ggblend::blend(blend = blend) +#' ), blend = blend +#' ) +#' +#' } +#' } diff --git a/R/gg_label.R b/R/gg_label.R index 2e56e1696..1b6a01770 100644 --- a/R/gg_label.R +++ b/R/gg_label.R @@ -21,7 +21,6 @@ #' gg_label( #' x = model, #' y = mpg, -#' col = mpg, #' label = model, #' y_expand_limits = 0, #' y_label = "Miles per gallon", @@ -52,14 +51,14 @@ gg_label <- function(data = NULL, text = NULL, sample = NULL, mapping = NULL, - x_breaks = NULL, x_breaks_n = NULL, + x_breaks = NULL, x_breaks_n = NULL, x_expand = NULL, x_expand_limits = NULL, - x_label = NULL, x_labels = NULL, - - - x_position = "bottom", - + x_label = NULL, x_labels = NULL, + + + x_position = "bottom", + x_sec_axis = ggplot2::waiver(), x_symmetric = NULL, x_transform = NULL, y_breaks = NULL, y_breaks_n = NULL, y_expand = NULL, @@ -67,8 +66,8 @@ gg_label <- function(data = NULL, y_label = NULL, y_labels = NULL, y_position = "left", y_sec_axis = ggplot2::waiver(), - y_symmetric = NULL, - + y_symmetric = NULL, + y_transform = NULL, col_breaks = NULL, col_breaks_n = 5, col_drop = FALSE, @@ -77,13 +76,13 @@ gg_label <- function(data = NULL, col_legend_ncol = NULL, col_legend_nrow = NULL, col_legend_rev = FALSE, - - + + col_palette = NULL, col_palette_na = NULL, col_rescale = scales::rescale(), col_steps = FALSE, - + col_transform = NULL, facet_axes = NULL, facet_axis_labels = "margins", @@ -149,7 +148,7 @@ gg_label <- function(data = NULL, col_legend_nrow = col_legend_nrow, col_legend_rev = col_legend_rev, col_breaks_n = col_breaks_n, - + col_palette = col_palette, col_palette_na = col_palette_na, col_rescale = col_rescale, diff --git a/R/gg_text.R b/R/gg_text.R index e8cccb300..d6b6e1f38 100644 --- a/R/gg_text.R +++ b/R/gg_text.R @@ -21,7 +21,6 @@ #' gg_text( #' x = model, #' y = mpg, -#' col = mpg, #' label = model, #' y_expand_limits = 0, #' y_label = "Miles per gallon", @@ -52,14 +51,14 @@ gg_text <- function(data = NULL, text = NULL, sample = NULL, mapping = NULL, - x_breaks = NULL, x_breaks_n = NULL, + x_breaks = NULL, x_breaks_n = NULL, x_expand = NULL, x_expand_limits = NULL, - x_label = NULL, x_labels = NULL, - - - x_position = "bottom", - + x_label = NULL, x_labels = NULL, + + + x_position = "bottom", + x_sec_axis = ggplot2::waiver(), x_symmetric = NULL, x_transform = NULL, y_breaks = NULL, y_breaks_n = NULL, y_expand = NULL, @@ -67,8 +66,8 @@ gg_text <- function(data = NULL, y_label = NULL, y_labels = NULL, y_position = "left", y_sec_axis = ggplot2::waiver(), - y_symmetric = NULL, - + y_symmetric = NULL, + y_transform = NULL, col_breaks = NULL, col_breaks_n = 5, col_drop = FALSE, @@ -77,13 +76,13 @@ gg_text <- function(data = NULL, col_legend_ncol = NULL, col_legend_nrow = NULL, col_legend_rev = FALSE, - - + + col_palette = NULL, col_palette_na = NULL, col_rescale = scales::rescale(), col_steps = FALSE, - + col_transform = NULL, facet_axes = NULL, facet_axis_labels = "margins", @@ -149,7 +148,7 @@ gg_text <- function(data = NULL, col_legend_nrow = col_legend_nrow, col_legend_rev = col_legend_rev, col_breaks_n = col_breaks_n, - + col_palette = col_palette, col_palette_na = col_palette_na, col_rescale = col_rescale, diff --git a/R/set_blanket.R b/R/set_blanket.R index 3fc49bb68..2337a1f2e 100644 --- a/R/set_blanket.R +++ b/R/set_blanket.R @@ -4,7 +4,7 @@ #' Weave the style by setting: #' #' 1. the mode to be added with `gg_*()` side-effects -#' 2. the colour/fill geom default, and other defaults for text, reference line and curve geoms +#' 2. the colour/fill geom defaults etc #' 3. the col_palettes for discrete, continuous and ordinal colour/fill scales #' 4. a theme to be added _without_ `gg_*()` side-effects. #' @@ -13,13 +13,19 @@ #' #' @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 colour A default hex colour for the colour of geoms (other than text or reference line geoms). -#' @param fill A default hex colour for the fill of geoms (other than text or reference line geoms). -#' @param text_colour A default hex colour for the colour (and fill) of the "text" and "label" geoms. -#' @param text_size A default size for the "text" and "label" geoms. -#' @param text_family A default family for the "text" and "label" geoms. -#' @param reference_line_colour A default hex colour for the colour of the "hline", "vline", "abline" and "curve" geoms. -#' @param reference_line_linewidth A default linewidth for the the "hline", "vline", "abline" and "curve" geoms. +#' @param colour A default hex colour for the colour of geoms. +#' @param colour_text A default hex colour for the colour of the "text" geom. +#' @param colour_label A default hex colour for the colour of the "label" geom. +#' @param colour_hline A default hex colour for the colour of the "hline" geom. +#' @param colour_vline A default hex colour for the colour of the vline" geom. +#' @param fill A default hex colour for the fill of geoms. +#' @param fill_label A default hex colour for the fill of the "label" geom. +#' @param size_text A default size for the "text" geom. +#' @param size_label A default size for the label" geom. +#' @param family_text A default family for the "text" geom. +#' @param family_label A default family for the "label" geom. +#' @param linewidth_hline A default hex colour for the colour of the "hline" geom. +#' @param linewidth_vline A default hex colour for the colour of the "vline" geom. #' @param col_palette_d For a discrete scale, a character vector of hex codes. #' @param col_palette_c For a continuous scale, a character vector of hex codes. #' @param col_palette_o For an ordinal scale, a `scales::pal_*()` function. @@ -39,8 +45,9 @@ #' set_blanket( #' mode = dark_mode_r(), #' colour = "#E7298AFF", -#' text_colour = darkness[1], -#' reference_line_colour = darkness[1], +#' colour_text = darkness[1], +#' colour_hline = darkness[1], +#' colour_vline = darkness[1], #' col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF", #' "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"), #' ) @@ -65,12 +72,18 @@ set_blanket <- function( ..., mode = light_mode_r(), colour = "#357BA2FF", + colour_text = "#121B24FF", + colour_label = "#FFFFFFFF", + colour_hline = "#121B24FF", + colour_vline = "#121B24FF", fill = colour, - text_colour = "#121B24FF", - text_size = 11 / 2.835052, - text_family = "", - reference_line_colour = "#121B24FF", - reference_line_linewidth = 0.33, + fill_label = "#121B24FF", + size_text = 11 / 2.835052, + size_label = size_text, + family_text = "", + family_label = family_text, + linewidth_hline = 0.25, + linewidth_vline = 0.25, col_palette_d = jumble, col_palette_c = viridisLite::mako(n = 9, direction = -1), col_palette_o = scales::pal_viridis(option = "G", direction = -1), @@ -83,12 +96,18 @@ set_blanket <- function( weave_geom_defaults( colour = colour, + colour_text = colour_text, + colour_label = colour_label, + colour_hline = colour_hline, + colour_vline = colour_vline, fill = fill, - text_colour = text_colour, - text_size = text_size, - text_family = text_family, - reference_line_colour = reference_line_colour, - reference_line_linewidth = reference_line_linewidth + fill_label = fill_label, + size_text = size_text, + size_label = size_label, + family_text = family_text, + family_label = family_label, + linewidth_hline = linewidth_hline, + linewidth_vline = linewidth_vline ) weave_col_palettes( diff --git a/R/weave.R b/R/weave.R index dfc2821fe..c65157f39 100644 --- a/R/weave.R +++ b/R/weave.R @@ -25,27 +25,40 @@ weave_mode <- function(mode = light_mode_r()) { #' Set a series of geom defaults #' -#' @description Update the colour/fill geom default, and update other defaults for text and reference line geoms. +#' @description Update all the geom defaults. #' -#' [ggplot2::update_geom_defaults()] can be used to further fine-tune geom defaults. +#' [ggplot2::update_geom_defaults()] can be used to further fine-tune individual geom defaults. #' -#' @param colour A default hex colour for the colour of geoms (other than text or reference line geoms). -#' @param fill A default hex colour for the fill of geoms (other than text or reference line geoms). -#' @param text_colour A default hex colour for the colour (and fill) of the "text" and "label" geoms. -#' @param text_size A default size for the "text" and "label" geoms. -#' @param text_family A default family for the "text" and "label" geoms. -#' @param reference_line_colour A default hex colour for the colour of the "hline", "vline", "abline" and "curve" geoms. -#' @param reference_line_linewidth A default linewidth for the the "hline", "vline", "abline" and "curve" geoms. +#' @param colour A default hex colour for the colour of geoms. +#' @param colour_text A default hex colour for the colour of the "text" geom. +#' @param colour_label A default hex colour for the colour of the "label" geom. +#' @param colour_hline A default hex colour for the colour of the "hline" geom. +#' @param colour_vline A default hex colour for the colour of the vline" geom. +#' @param fill A default hex colour for the fill of geoms. +#' @param fill_label A default hex colour for the fill of the "label" geom. +#' @param size_text A default size for the "text" geom. +#' @param size_label A default size for the label" geom. +#' @param family_text A default family for the "text" geom. +#' @param family_label A default family for the "label" geom. +#' @param linewidth_hline A default hex colour for the colour of the "hline" geom. +#' @param linewidth_vline A default hex colour for the colour of the "vline" geom. #' #' @export weave_geom_defaults <- function( colour = "#357BA2FF", + colour_text = "#121B24FF", + colour_label = "#FFFFFFFF", + colour_hline = "#121B24FF", + colour_vline = "#121B24FF", fill = colour, - text_colour = "#121B24FF", - text_size = 11 / 2.835052, - text_family = "", - reference_line_colour = "#121B24FF", - reference_line_linewidth = 0.33) { + fill_label = "#121B24FF", + size_text = 11 / 2.835052, + size_label = size_text, + family_text = "", + family_label = family_text, + linewidth_hline = 0.25, + linewidth_vline = 0.25 + ) { #polygons ggplot2::update_geom_defaults("area", ggplot2::aes(colour = !!colour, fill = !!fill, linewidth = 0)) @@ -70,7 +83,9 @@ weave_geom_defaults <- function( ggplot2::update_geom_defaults("hex", ggplot2::aes(fill = !!fill, linewidth = 0)) #lines + ggplot2::update_geom_defaults("abline", ggplot2::aes(colour = !!colour, linewidth = 0.66)) ggplot2::update_geom_defaults("contour", ggplot2::aes(colour = !!colour, linewidth = 0.66)) + ggplot2::update_geom_defaults("curve", ggplot2::aes(colour = !!colour, linewidth = 0.66)) ggplot2::update_geom_defaults("density2d", ggplot2::aes(colour = !!colour, linewidth = 0.66)) ggplot2::update_geom_defaults("errorbar", ggplot2::aes(colour = !!colour, linewidth = 0.66)) ggplot2::update_geom_defaults("function", ggplot2::aes(colour = !!colour, linewidth = 0.66)) @@ -87,15 +102,13 @@ weave_geom_defaults <- function( ggplot2::update_geom_defaults("point", ggplot2::aes(colour = !!colour, fill = !!fill)) ggplot2::update_geom_defaults("pointrange", ggplot2::aes(colour = !!colour, fill = !!fill, linewidth = 0.66, size = 0.2)) # 1.5 / 7.5 - #reference lines - ggplot2::update_geom_defaults("abline", ggplot2::aes(colour = !!reference_line_colour, linewidth = !!reference_line_linewidth)) - ggplot2::update_geom_defaults("hline", ggplot2::aes(colour = !!reference_line_colour, linewidth = !!reference_line_linewidth)) - ggplot2::update_geom_defaults("vline", ggplot2::aes(colour = !!reference_line_colour, linewidth = !!reference_line_linewidth)) - ggplot2::update_geom_defaults("curve", ggplot2::aes(colour = !!reference_line_colour, linewidth = !!reference_line_linewidth)) + #hline & vline + ggplot2::update_geom_defaults("hline", ggplot2::aes(colour = !!colour_hline, linewidth = !!linewidth_hline)) + ggplot2::update_geom_defaults("vline", ggplot2::aes(colour = !!colour_vline, linewidth = !!linewidth_vline)) - #text - ggplot2::update_geom_defaults("text", ggplot2::aes(colour = !!text_colour, size = !!text_size, family = !!text_family)) - ggplot2::update_geom_defaults("label", ggplot2::aes(colour = !!text_colour, fill = !!text_colour, alpha = 0.05, size = !!text_size, family = !!text_family)) + #text and label + ggplot2::update_geom_defaults("text", ggplot2::aes(colour = !!colour_text, size = !!size_text, family = !!family_text)) + ggplot2::update_geom_defaults("label", ggplot2::aes(colour = !!colour_label, fill = !!fill_label, size = !!size_label, family = !!family_label)) } #' Set a discrete colour and fill palettes diff --git a/man/gg_label.Rd b/man/gg_label.Rd index baf7a8a37..1fd36bda9 100644 --- a/man/gg_label.Rd +++ b/man/gg_label.Rd @@ -175,7 +175,6 @@ bind_rows( gg_label( x = model, y = mpg, - col = mpg, label = model, y_expand_limits = 0, y_label = "Miles per gallon", diff --git a/man/gg_text.Rd b/man/gg_text.Rd index 824c1bc24..55994d259 100644 --- a/man/gg_text.Rd +++ b/man/gg_text.Rd @@ -175,7 +175,6 @@ bind_rows( gg_text( x = model, y = mpg, - col = mpg, label = model, y_expand_limits = 0, y_label = "Miles per gallon", diff --git a/man/set_blanket.Rd b/man/set_blanket.Rd index 412ec8cfb..7d85e1e83 100644 --- a/man/set_blanket.Rd +++ b/man/set_blanket.Rd @@ -8,12 +8,18 @@ set_blanket( ..., mode = light_mode_r(), colour = "#357BA2FF", + colour_text = "#121B24FF", + colour_label = "#FFFFFFFF", + colour_hline = "#121B24FF", + colour_vline = "#121B24FF", fill = colour, - text_colour = "#121B24FF", - text_size = 11/2.835052, - text_family = "", - reference_line_colour = "#121B24FF", - reference_line_linewidth = 0.33, + fill_label = "#121B24FF", + size_text = 11/2.835052, + size_label = size_text, + family_text = "", + family_label = family_text, + linewidth_hline = 0.25, + linewidth_vline = 0.25, col_palette_d = jumble, col_palette_c = viridisLite::mako(n = 9, direction = -1), col_palette_o = scales::pal_viridis(option = "G", direction = -1), @@ -28,19 +34,31 @@ set_blanket( \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}.} -\item{colour}{A default hex colour for the colour of geoms (other than text or reference line geoms).} +\item{colour}{A default hex colour for the colour of geoms.} -\item{fill}{A default hex colour for the fill of geoms (other than text or reference line geoms).} +\item{colour_text}{A default hex colour for the colour of the "text" geom.} -\item{text_colour}{A default hex colour for the colour (and fill) of the "text" and "label" geoms.} +\item{colour_label}{A default hex colour for the colour of the "label" geom.} -\item{text_size}{A default size for the "text" and "label" geoms.} +\item{colour_hline}{A default hex colour for the colour of the "hline" geom.} -\item{text_family}{A default family for the "text" and "label" geoms.} +\item{colour_vline}{A default hex colour for the colour of the vline" geom.} -\item{reference_line_colour}{A default hex colour for the colour of the "hline", "vline", "abline" and "curve" geoms.} +\item{fill}{A default hex colour for the fill of geoms.} -\item{reference_line_linewidth}{A default linewidth for the the "hline", "vline", "abline" and "curve" geoms.} +\item{fill_label}{A default hex colour for the fill of the "label" geom.} + +\item{size_text}{A default size for the "text" geom.} + +\item{size_label}{A default size for the label" geom.} + +\item{family_text}{A default family for the "text" geom.} + +\item{family_label}{A default family for the "label" geom.} + +\item{linewidth_hline}{A default hex colour for the colour of the "hline" geom.} + +\item{linewidth_vline}{A default hex colour for the colour of the "vline" geom.} \item{col_palette_d}{For a discrete scale, a character vector of hex codes.} @@ -63,7 +81,7 @@ A globally set style. Weave the style by setting: \enumerate{ \item the mode to be added with \verb{gg_*()} side-effects -\item the colour/fill geom default, and other defaults for text, reference line and curve geoms +\item the colour/fill geom defaults etc \item the col_palettes for discrete, continuous and ordinal colour/fill scales \item a theme to be added \emph{without} \verb{gg_*()} side-effects. } @@ -79,8 +97,9 @@ library(palmerpenguins) set_blanket( mode = dark_mode_r(), colour = "#E7298AFF", - text_colour = darkness[1], - reference_line_colour = darkness[1], + colour_text = darkness[1], + colour_hline = darkness[1], + colour_vline = darkness[1], col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF", "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"), ) diff --git a/man/weave_geom_defaults.Rd b/man/weave_geom_defaults.Rd index 1b67348c5..a667b7d0a 100644 --- a/man/weave_geom_defaults.Rd +++ b/man/weave_geom_defaults.Rd @@ -6,31 +6,49 @@ \usage{ weave_geom_defaults( colour = "#357BA2FF", + colour_text = "#121B24FF", + colour_label = "#FFFFFFFF", + colour_hline = "#121B24FF", + colour_vline = "#121B24FF", fill = colour, - text_colour = "#121B24FF", - text_size = 11/2.835052, - text_family = "", - reference_line_colour = "#121B24FF", - reference_line_linewidth = 0.33 + fill_label = "#121B24FF", + size_text = 11/2.835052, + size_label = size_text, + family_text = "", + family_label = family_text, + linewidth_hline = 0.25, + linewidth_vline = 0.25 ) } \arguments{ -\item{colour}{A default hex colour for the colour of geoms (other than text or reference line geoms).} +\item{colour}{A default hex colour for the colour of geoms.} -\item{fill}{A default hex colour for the fill of geoms (other than text or reference line geoms).} +\item{colour_text}{A default hex colour for the colour of the "text" geom.} -\item{text_colour}{A default hex colour for the colour (and fill) of the "text" and "label" geoms.} +\item{colour_label}{A default hex colour for the colour of the "label" geom.} -\item{text_size}{A default size for the "text" and "label" geoms.} +\item{colour_hline}{A default hex colour for the colour of the "hline" geom.} -\item{text_family}{A default family for the "text" and "label" geoms.} +\item{colour_vline}{A default hex colour for the colour of the vline" geom.} -\item{reference_line_colour}{A default hex colour for the colour of the "hline", "vline", "abline" and "curve" geoms.} +\item{fill}{A default hex colour for the fill of geoms.} -\item{reference_line_linewidth}{A default linewidth for the the "hline", "vline", "abline" and "curve" geoms.} +\item{fill_label}{A default hex colour for the fill of the "label" geom.} + +\item{size_text}{A default size for the "text" geom.} + +\item{size_label}{A default size for the label" geom.} + +\item{family_text}{A default family for the "text" geom.} + +\item{family_label}{A default family for the "label" geom.} + +\item{linewidth_hline}{A default hex colour for the colour of the "hline" geom.} + +\item{linewidth_vline}{A default hex colour for the colour of the "vline" geom.} } \description{ -Update the colour/fill geom default, and update other defaults for text and reference line geoms. +Update all the geom defaults. -\code{\link[ggplot2:update_defaults]{ggplot2::update_geom_defaults()}} can be used to further fine-tune geom defaults. +\code{\link[ggplot2:update_defaults]{ggplot2::update_geom_defaults()}} can be used to further fine-tune individual geom defaults. } diff --git a/tests/testthat/_snaps/article-demo-light/gg-label.svg b/tests/testthat/_snaps/article-demo-light/gg-label.svg index 7ebabfd13..f57b4b549 100644 --- a/tests/testthat/_snaps/article-demo-light/gg-label.svg +++ b/tests/testthat/_snaps/article-demo-light/gg-label.svg @@ -19,24 +19,24 @@ - - - - - - - - - - - - - -Cadillac Fleetwood - -Lincoln Continental - -Toyota Corolla + + + + + + + + + + + + + +Cadillac Fleetwood + +Lincoln Continental + +Toyota Corolla 0 5 @@ -54,29 +54,14 @@ - - - - -Cadillac Fleetwood -Lincoln Continental -Toyota Corolla -Model + + + + +Cadillac Fleetwood +Lincoln Continental +Toyota Corolla +Model Miles per gallon - -Mpg - - - - - - - - - -15 -20 -25 -30 diff --git a/tests/testthat/_snaps/article-demo-light/gg-text.svg b/tests/testthat/_snaps/article-demo-light/gg-text.svg index a6e30c4c2..24cab1e31 100644 --- a/tests/testthat/_snaps/article-demo-light/gg-text.svg +++ b/tests/testthat/_snaps/article-demo-light/gg-text.svg @@ -19,21 +19,21 @@ - - - - - - - - - - - - -Cadillac Fleetwood -Lincoln Continental -Toyota Corolla + + + + + + + + + + + + +Cadillac Fleetwood +Lincoln Continental +Toyota Corolla 0 5 @@ -51,29 +51,14 @@ - - - - -Cadillac Fleetwood -Lincoln Continental -Toyota Corolla -Model + + + + +Cadillac Fleetwood +Lincoln Continental +Toyota Corolla +Model Miles per gallon - -Mpg - - - - - - - - - -15 -20 -25 -30 diff --git a/tests/testthat/_snaps/lineribbon/datetime.svg b/tests/testthat/_snaps/ribbon-line/datetime.svg similarity index 100% rename from tests/testthat/_snaps/lineribbon/datetime.svg rename to tests/testthat/_snaps/ribbon-line/datetime.svg diff --git a/tests/testthat/_snaps/set_blanket/1.svg b/tests/testthat/_snaps/set_blanket/1.svg index 5acd1dfdd..09ddcae89 100644 --- a/tests/testthat/_snaps/set_blanket/1.svg +++ b/tests/testthat/_snaps/set_blanket/1.svg @@ -392,7 +392,7 @@ - + 2,500 3,000 3,500 diff --git a/tests/testthat/_snaps/set_blanket/2.svg b/tests/testthat/_snaps/set_blanket/2.svg index 669906f6e..1d98ebb1d 100644 --- a/tests/testthat/_snaps/set_blanket/2.svg +++ b/tests/testthat/_snaps/set_blanket/2.svg @@ -384,7 +384,7 @@ - + 2,500 3,000 diff --git a/tests/testthat/test-article-demo-light.R b/tests/testthat/test-article-demo-light.R index 1c74c3aa3..85e372fd2 100644 --- a/tests/testthat/test-article-demo-light.R +++ b/tests/testthat/test-article-demo-light.R @@ -298,7 +298,6 @@ test_that(test_name, { gg_label( x = model, y = mpg, - col = mpg, label = model, size = 3.53, y_expand_limits = 0, @@ -612,7 +611,6 @@ test_that(test_name, { gg_text( x = model, y = mpg, - col = mpg, label = model, size = 3.53, y_expand_limits = 0, diff --git a/tests/testthat/test-set_blanket.R b/tests/testthat/test-set_blanket.R index 62934b4d7..cf5d32a76 100644 --- a/tests/testthat/test-set_blanket.R +++ b/tests/testthat/test-set_blanket.R @@ -35,8 +35,8 @@ test_that(test_name, { set_blanket( mode = light_mode_r(), colour = red, - text_colour = teal, - reference_line_colour = teal, + colour_text = teal, + colour_vline = teal, ) p <- penguins |> @@ -56,10 +56,10 @@ test_that(test_name, { set_blanket( mode = dark_mode_r(base_size = 15), colour = red, - text_colour = "red", - reference_line_colour = "red", - reference_line_linewidth = 5, - text_size = 15 / 2.83505, + colour_text = "red", + colour_vline = "red", + linewidth_vline = 5, + size_text = 15 / 2.83505, col_palette_d = c(navy, red, "green"), col_palette_c = c(navy, purple, red, orange) ) diff --git a/vignettes/articles/1_demo_light.Rmd b/vignettes/articles/1_demo_light.Rmd index 5b70197c6..ecd1ece8e 100644 --- a/vignettes/articles/1_demo_light.Rmd +++ b/vignettes/articles/1_demo_light.Rmd @@ -275,7 +275,6 @@ bind_rows( gg_label( x = model, y = mpg, - col = mpg, label = model, y_expand_limits = 0, y_label = "Miles per gallon", @@ -532,7 +531,6 @@ bind_rows( gg_text( x = model, y = mpg, - col = mpg, label = model, y_expand_limits = 0, y_label = "Miles per gallon", diff --git a/vignettes/articles/2_demo_dark.Rmd b/vignettes/articles/2_demo_dark.Rmd index 94bf94902..e79ed7e45 100644 --- a/vignettes/articles/2_demo_dark.Rmd +++ b/vignettes/articles/2_demo_dark.Rmd @@ -29,8 +29,9 @@ library(palmerpenguins) set_blanket( mode = dark_mode_r(), - text_colour = darkness[1], - reference_line_colour = darkness[1], + colour_text = darkness[1], + colour_hline = darkness[1], + colour_vline = darkness[1], col_palette_d = c(teal, orange, purple, red, pink, navy), col_palette_c = viridis::mako(n = 9), col_palette_o = scales::pal_viridis(option = "G"), @@ -282,7 +283,6 @@ bind_rows( gg_label( x = model, y = mpg, - col = mpg, label = model, y_expand_limits = 0, y_label = "Miles per gallon", @@ -539,7 +539,6 @@ bind_rows( gg_text( x = model, y = mpg, - col = mpg, label = model, y_expand_limits = 0, y_label = "Miles per gallon", diff --git a/vignettes/ggblanket.Rmd b/vignettes/ggblanket.Rmd index aab72647c..b40172abf 100644 --- a/vignettes/ggblanket.Rmd +++ b/vignettes/ggblanket.Rmd @@ -372,8 +372,9 @@ The `ggplot2::update_geom_defaults()` function can be used to further fine-tune set_blanket( mode = dark_mode_r(), colour = "#E7298AFF", - text_colour = darkness[1], - reference_line_colour = darkness[1], + colour_text = darkness[1], + colour_hline = darkness[1], + colour_vline = darkness[1], col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF", "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"), )