From 484a4358491d8a35bd77ce39d217814288c853d5 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 12 Mar 2026 16:18:21 -0400 Subject: [PATCH 1/3] Remove viridislite pkg from theme_noaa() as per https://github.com/nmfs-ost/stockplotr/issues/204#issuecomment-4048764333 --- R/theme_noaa.R | 53 ++++++++++++++++++++++++++++------------------- kq_plan_notes.R | 18 ++++++++++++++++ man/theme_noaa.Rd | 13 +++++++++++- 3 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 kq_plan_notes.R diff --git a/R/theme_noaa.R b/R/theme_noaa.R index f502a6e4..4dce8672 100644 --- a/R/theme_noaa.R +++ b/R/theme_noaa.R @@ -17,9 +17,20 @@ #' ) + #' ggplot2::geom_point() + #' theme_noaa() -#' \dontrun{ -#' ggplot2::theme_set(stockplotr::theme_noaa()) -#' } +#' +#' ggplot2::ggplot( +#' data = OrchardSprays, +#' ggplot2::aes( +#' x = rowpos, +#' y = decrease, +#' color = decrease +#' ) +#' ) + +#' ggplot2::geom_point() + +#' theme_noaa(discrete = FALSE) +#'\dontrun{ +#' ggplot2::theme_set(stockplotr::theme_noaa()) +#'} theme_noaa <- function(discrete = TRUE, ...) { if (utils::packageVersion("ggplot2") < "4.0.0") { @@ -29,8 +40,14 @@ theme_noaa <- function(discrete = TRUE, .frequency_id = "ggplot2_version_warning" ) } - - theme <- ggplot2::theme_bw() + + + mako_pal_discrete <- scales::pal_viridis(begin = 0.1, end = 0.85, option = "G") + + mako_pal_continuous <- scales::gradient_n_pal( + scales::pal_viridis(begin = 0.1, end = 0.85, option = "G")(6) + ) + + thm <- ggplot2::theme_bw() + ggplot2::theme( plot.background = ggplot2::element_rect(fill = "transparent"), panel.background = ggplot2::element_rect(fill = "transparent"), @@ -40,23 +57,17 @@ theme_noaa <- function(discrete = TRUE, plot.margin = ggplot2::margin(0.5, 1, 0.5, 0.5, "cm"), ... ) - - # create main palette - pal <- function(n) viridisLite::mako(n, begin = 0.1, end = 0.85) - + if (discrete) { - theme <- theme + - ggplot2::theme( - palette.colour.discrete = pal, - palette.fill.discrete = pal - ) + thm <- thm + ggplot2::theme( + palette.colour.discrete = mako_pal_discrete, + palette.fill.discrete = mako_pal_discrete + ) } else { - theme <- theme + - ggplot2::theme( - palette.colour.continuous = pal, - palette.fill.continuous = pal - ) + thm <- thm + ggplot2::theme( + palette.colour.continuous = mako_pal_continuous, + palette.fill.continuous = mako_pal_continuous + ) } - - theme + thm } diff --git a/kq_plan_notes.R b/kq_plan_notes.R new file mode 100644 index 00000000..185336f4 --- /dev/null +++ b/kq_plan_notes.R @@ -0,0 +1,18 @@ +# setup +# +# 1. create csv with cols "key_quantity", "value", "meaning", "calc dependent on other key quantity", "dependent key quantity", "calc dependent on user", "function with required input"- TEMPLATE +# 2. KQs calc'd on a fxn-by-fxn basis, and csv is updated each time unless non-NA value present +# 3. If KQ depends on other for calc, import that cell in the csv; if not NA, convert to number and calculate it. If NA, send message to console: user can add it manually OR run fxn that depends on it (see appropriate column) + + +unit_label = "metric tons" +geom = "line" +group = NULL +facet = NULL +era = NULL +scale_amount = 1 +module = NULL +interactive = TRUE +make_rda = FALSE +figures_dir = getwd() + diff --git a/man/theme_noaa.Rd b/man/theme_noaa.Rd index c23e3612..4117fd89 100644 --- a/man/theme_noaa.Rd +++ b/man/theme_noaa.Rd @@ -28,7 +28,18 @@ ggplot2::ggplot( ) + ggplot2::geom_point() + theme_noaa() + +ggplot2::ggplot( + data = OrchardSprays, + ggplot2::aes( + x = rowpos, + y = decrease, + color = decrease + ) +) + + ggplot2::geom_point() + + theme_noaa(discrete = FALSE) \dontrun{ -ggplot2::theme_set(stockplotr::theme_noaa()) + ggplot2::theme_set(stockplotr::theme_noaa()) } } From 0c2ec6e546d3f629788fb00bd59f9b4a8f575482 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 12 Mar 2026 16:27:57 -0400 Subject: [PATCH 2/3] Remove rlang pkg from theme_noaa() --- R/theme_noaa.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/theme_noaa.R b/R/theme_noaa.R index 4dce8672..6991e44b 100644 --- a/R/theme_noaa.R +++ b/R/theme_noaa.R @@ -34,8 +34,10 @@ theme_noaa <- function(discrete = TRUE, ...) { if (utils::packageVersion("ggplot2") < "4.0.0") { - rlang::warn( - message = paste0("Your `ggplot2` version is ", utils::packageVersion("ggplot2"), ", which is older than the version required to use `theme_noaa()` (4.0.0). Please update your `ggplot2` package."), + cli::cli_warn( + "Your {.pkg ggplot2} version is {.val {utils::packageVersion('ggplot2')}}, + which is older than the version required to use {.fn theme_noaa} (4.0.0). + Please update your {.pkg ggplot2} package.", .frequency = "once", .frequency_id = "ggplot2_version_warning" ) From 4cdf2e59f03085f5fe615f733bfa01e827667ba8 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 12 Mar 2026 16:35:39 -0400 Subject: [PATCH 3/3] Remove notes --- kq_plan_notes.R | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 kq_plan_notes.R diff --git a/kq_plan_notes.R b/kq_plan_notes.R deleted file mode 100644 index 185336f4..00000000 --- a/kq_plan_notes.R +++ /dev/null @@ -1,18 +0,0 @@ -# setup -# -# 1. create csv with cols "key_quantity", "value", "meaning", "calc dependent on other key quantity", "dependent key quantity", "calc dependent on user", "function with required input"- TEMPLATE -# 2. KQs calc'd on a fxn-by-fxn basis, and csv is updated each time unless non-NA value present -# 3. If KQ depends on other for calc, import that cell in the csv; if not NA, convert to number and calculate it. If NA, send message to console: user can add it manually OR run fxn that depends on it (see appropriate column) - - -unit_label = "metric tons" -geom = "line" -group = NULL -facet = NULL -era = NULL -scale_amount = 1 -module = NULL -interactive = TRUE -make_rda = FALSE -figures_dir = getwd() -