From 2671e54440dcb2fc46ba8c3c411162dbf4b4d41b Mon Sep 17 00:00:00 2001 From: Ernest Guevarra Date: Wed, 1 Jan 2025 18:35:07 +0000 Subject: [PATCH] create nhs brewer palettes; fix #104 --- NAMESPACE | 2 + NEWS.md | 4 +- R/theme_acdc.R | 3 +- R/theme_nhs.R | 131 +++++++++++++++++++++++++++++++-------------- man/nhs_colours.Rd | 5 ++ man/nhs_palette.Rd | 9 +++- man/theme_acdc.Rd | 2 +- 7 files changed, 111 insertions(+), 45 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 4d03f12..bb1977c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,12 +28,14 @@ export(nhs_aqua_blue) export(nhs_aqua_green) export(nhs_black) export(nhs_blue) +export(nhs_brewer_palettes) export(nhs_bright_blue) export(nhs_dark_blue) export(nhs_dark_green) export(nhs_dark_grey) export(nhs_dark_pink) export(nhs_dark_red) +export(nhs_emergency_red) export(nhs_fonts) export(nhs_green) export(nhs_light_blue) diff --git a/NEWS.md b/NEWS.md index 3fc4233..2b787ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,9 @@ * Changed Africa CDC colour palettes based on updated communication style guidelines -* Created sequential and divergent Africa CDC colour palettes +* Created Africa CDC brewer base palettes + +* Created palette brewer functions for sequential, divergent, and qualitative colour palettes ## General updates diff --git a/R/theme_acdc.R b/R/theme_acdc.R index a7df77c..a3006eb 100644 --- a/R/theme_acdc.R +++ b/R/theme_acdc.R @@ -108,6 +108,7 @@ acdc_palettes <- list( acdc_teals = c("#CCE9E6", "#99D3CD", "#66BEB4", "#33A89B", acdc_teal) ) + #' #' @examples #' acdc_brewer_palettes @@ -347,7 +348,7 @@ theme_acdc_dark <- function(base_family = set_acdc_font(), axis_title_colour = acdc_white, legend_title_colour = acdc_white, legend_text_colour = acdc_white, - plot_background_fill = tint_colour(acdc_gold, 0.2), + plot_background_fill = tint_colour(acdc_gold, 0.8), grid_col = acdc_green, grid = TRUE, axis_col = acdc_green, diff --git a/R/theme_nhs.R b/R/theme_nhs.R index 2d23aa6..28e8c76 100644 --- a/R/theme_nhs.R +++ b/R/theme_nhs.R @@ -8,87 +8,91 @@ #' @rdname nhs_colours #' @export #' -nhs_blue <- "#005EB8" +nhs_blue <- "#005EB8" #' @rdname nhs_colours #' @export -nhs_white <- "#FFFFFF" +nhs_white <- "#FFFFFF" #' @rdname nhs_colours #' @export -nhs_dark_blue <- "#003087" +nhs_dark_blue <- "#003087" #' @rdname nhs_colours #' @export -nhs_bright_blue <- "#0072CE" +nhs_bright_blue <- "#0072CE" #' @rdname nhs_colours #' @export -nhs_light_blue <- "#41B6E6" +nhs_light_blue <- "#41B6E6" #' @rdname nhs_colours #' @export -nhs_aqua_blue <- "#00A9CE" +nhs_aqua_blue <- "#00A9CE" #' @rdname nhs_colours #' @export -nhs_black <- "#231f20" +nhs_black <- "#231f20" #' @rdname nhs_colours #' @export -nhs_dark_grey <- "#425563" +nhs_dark_grey <- "#425563" #' @rdname nhs_colours #' @export -nhs_mid_grey <- "#768692" +nhs_mid_grey <- "#768692" #' @rdname nhs_colours #' @export -nhs_pale_grey <- "#E8EDEE" +nhs_pale_grey <- "#E8EDEE" #' @rdname nhs_colours #' @export -nhs_dark_green <- "#006747" +nhs_dark_green <- "#006747" #' @rdname nhs_colours #' @export -nhs_green <- "#009639" +nhs_green <- "#009639" #' @rdname nhs_colours #' @export -nhs_light_green <- "#78BE20" +nhs_light_green <- "#78BE20" #' @rdname nhs_colours #' @export -nhs_aqua_green <- "#00A499" +nhs_aqua_green <- "#00A499" #' @rdname nhs_colours #' @export -nhs_purple <- "#330072" +nhs_purple <- "#330072" #' @rdname nhs_colours #' @export -nhs_dark_pink <- "#7C2855" +nhs_dark_pink <- "#7C2855" #' @rdname nhs_colours #' @export -nhs_pink <- "#AE2573" +nhs_pink <- "#AE2573" #' @rdname nhs_colours #' @export -nhs_dark_red <- "#8A1538" +nhs_emergency_red <- "#DA291C" #' @rdname nhs_colours #' @export -nhs_orange <- "#ED8B00" +nhs_dark_red <- "#8A1538" #' @rdname nhs_colours #' @export -nhs_warm_yellow <- "#FFB81C" +nhs_orange <- "#ED8B00" #' @rdname nhs_colours #' @export -nhs_yellow <- "#FAE100" +nhs_warm_yellow <- "#FFB81C" + +#' @rdname nhs_colours +#' @export +nhs_yellow <- "#FAE100" #' @@ -108,26 +112,71 @@ nhs_palettes <- list( nhs_highlights = c( "#330072", "#7C2855", "#AE2573", "#8A1538", "#ED8B00", "#FFB81C", "#FAE100" ), - nhs_dark_blues = c("#003087", "#33599F", "#6682B7", "#99ACCF", "#CCD5E7"), - nhs_blues = c("#005EB8", "#337EC6", "#669ED4", "#99BEE2", "#CCDEF0"), - nhs_bright_blues = c("#0072CE", "#338ED7", "#66AAE1", "#99C6EB", "#CCE2F5"), - nhs_light_blues = c("#41B6E6", "#67C4EB", "#8DD3F0", "#B3E1F5", "#D9F0FA"), - nhs_aqua_blues = c("#00A9CE", "#33BAD7", "#66CBE1", "#99DCEB", "#CCEDF5"), - nhs_blacks = c("#231f20", "#4F4B4C", "#7B7879", "#A7A5A5", "#D3D2D2"), - nhs_dark_greys = c("#425563", "#677782", "#8D99A1", "#B3BBC0", "#D9DDDF"), - nhs_mid_greys = c("#768692", "#919EA7", "#ACB6BD", "#C8CED3", "#E3E6E9"), - nhs_pale_greys = c("#E8EDEE", "#ECF0F1", "#F1F4F4", "#F5F7F8", "#FAFBFB"), - nhs_dark_greens = c("#006747", "#33856B", "#66A390", "#99C2B5", "#CCE0DA"), - nhs_greens = c("#009639", "#33AB60", "#66C088", "#99D5AF", "#CCEAD7"), - nhs_light_greens = c("#78BE20", "#93CB4C", "#AED879", "#C9E5A5", "#E4F2D2"), - nhs_aqua_greens = c("#00A499", "#33B6AD", "#66C8C1", "#99DAD6", "#CCECEA"), - nhs_purples = c("#330072", "#5B338E", "#8466AA", "#AD99C6", "#D6CCE2"), - nhs_dark_pinks = c("#7C2855", "#965377", "#B07E99", "#CAA9BB", "#E4D4DD"), - nhs_pinks = c("#AE2573", "#BE508F", "#CE7CAB", "#DEA7C7", "#EED3E3"), - nhs_dark_reds = c("#8A1538", "#A1435F", "#B87287", "#D0A1AF", "#E7D0D7"), - nhs_oranges = c("#ED8B00", "#F0A233", "#F4B966", "#F7D099", "#FBE7CC"), - nhs_warm_yellows = c("#FFB81C", "#FFC649", "#FFD476", "#FFE2A4", "#FFF0D1"), - nhs_yellows = c("#FAE100", "#FBE733", "#FCED66", "#FDF399", "#FEF9CC") + nhs_dark_blues = rev(c("#003087", "#33599F", "#6682B7", "#99ACCF", "#CCD5E7")), + nhs_blues = rev(c("#005EB8", "#337EC6", "#669ED4", "#99BEE2", "#CCDEF0")), + nhs_bright_blues = rev(c("#0072CE", "#338ED7", "#66AAE1", "#99C6EB", "#CCE2F5")), + nhs_light_blues = rev(c("#41B6E6", "#67C4EB", "#8DD3F0", "#B3E1F5", "#D9F0FA")), + nhs_aqua_blues = rev(c("#00A9CE", "#33BAD7", "#66CBE1", "#99DCEB", "#CCEDF5")), + nhs_blacks = rev(c("#231f20", "#4F4B4C", "#7B7879", "#A7A5A5", "#D3D2D2")), + nhs_dark_greys = rev(c("#425563", "#677782", "#8D99A1", "#B3BBC0", "#D9DDDF")), + nhs_mid_greys = rev(c("#768692", "#919EA7", "#ACB6BD", "#C8CED3", "#E3E6E9")), + nhs_pale_greys = rev(c("#E8EDEE", "#ECF0F1", "#F1F4F4", "#F5F7F8", "#FAFBFB")), + nhs_dark_greens = rev(c("#006747", "#33856B", "#66A390", "#99C2B5", "#CCE0DA")), + nhs_greens = rev(c("#009639", "#33AB60", "#66C088", "#99D5AF", "#CCEAD7")), + nhs_light_greens = rev(c("#78BE20", "#93CB4C", "#AED879", "#C9E5A5", "#E4F2D2")), + nhs_aqua_greens = rev(c("#00A499", "#33B6AD", "#66C8C1", "#99DAD6", "#CCECEA")), + nhs_purples = rev(c("#330072", "#5B338E", "#8466AA", "#AD99C6", "#D6CCE2")), + nhs_dark_pinks = rev(c("#7C2855", "#965377", "#B07E99", "#CAA9BB", "#E4D4DD")), + nhs_pinks = rev(c("#AE2573", "#BE508F", "#CE7CAB", "#DEA7C7", "#EED3E3")), + nhs_dark_reds = rev(c("#8A1538", "#A1435F", "#B87287", "#D0A1AF", "#E7D0D7")), + nhs_reds = rev(c("#DA291C", "#E15349", "#E87E76", "#F0A9A4", "#F7D4D1")), + nhs_oranges = rev(c("#ED8B00", "#F0A233", "#F4B966", "#F7D099", "#FBE7CC")), + nhs_warm_yellows = rev(c("#FFB81C", "#FFC649", "#FFD476", "#FFE2A4", "#FFF0D1")), + nhs_yellows = rev(c("#FAE100", "#FBE733", "#FCED66", "#FDF399", "#FEF9CC")) +) + + +#' +#' @examples +#' nhs_brewer_palettes +#' +#' @rdname nhs_palette +#' @export +#' + +nhs_brewer_palettes <- list( + blues = c(nhs_light_blue, nhs_blue, nhs_bright_blue), + bugn = c(nhs_light_blue, nhs_aqua_green, nhs_green), + bupu = c(nhs_dark_blue, nhs_dark_pink, nhs_purple), + gnbu = c(nhs_aqua_green, nhs_aqua_blue, nhs_bright_blue), + greens = c(nhs_light_green, nhs_green, nhs_dark_green), + greys = c(nhs_pale_grey, nhs_mid_grey, nhs_dark_grey), + pubu = c(nhs_purple, nhs_dark_pink, nhs_dark_blue), + pubugn = c(nhs_purple, nhs_blue, nhs_green), + purd = c(nhs_purple, nhs_dark_pink, nhs_dark_red), + rdpu = c(nhs_dark_red, nhs_dark_pink, nhs_purple), + reds = c(nhs_emergency_red, nhs_pink, nhs_dark_red), + ylgn = c(nhs_yellow, nhs_aqua_green, nhs_dark_green), + ylgnbu = c(nhs_yellow, nhs_aqua_blue, nhs_dark_blue), + ylorrd = c(nhs_yellow, nhs_orange, nhs_dark_red), + piylgn = c(nhs_pink, nhs_yellow, nhs_green), + prgn = c(nhs_purple, nhs_pink, nhs_dark_green), + puor = c(nhs_purple, nhs_emergency_red, nhs_orange), + rdbu = c(nhs_dark_red, nhs_purple, nhs_dark_blue), + rdgy = c(nhs_dark_red, nhs_emergency_red, nhs_mid_grey), + rdylbu = c(nhs_emergency_red, nhs_yellow, nhs_bright_blue), + rdylgn = c(nhs_emergency_red, nhs_yellow, nhs_green), + pastel1 = c( + nhs_palettes$nhs_light_blues[3], nhs_palettes$nhs_bright_blues[3], + nhs_palettes$nhs_greens[3], nhs_palettes$nhs_light_greens[3], + nhs_palettes$nhs_pinks[3], nhs_palettes$nhs_purples[3], + nhs_palettes$nhs_reds[3], nhs_palettes$nhs_oranges[3] + ), + dark = c( + nhs_palettes$nhs_dark_blues[4], nhs_palettes$nhs_dark_greens[4], + nhs_palettes$nhs_dark_reds[4], nhs_palettes$nhs_purples[4], + nhs_palettes$nhs_dark_greys[4] + ) ) diff --git a/man/nhs_colours.Rd b/man/nhs_colours.Rd index 8627809..2f420db 100644 --- a/man/nhs_colours.Rd +++ b/man/nhs_colours.Rd @@ -19,6 +19,7 @@ \alias{nhs_purple} \alias{nhs_dark_pink} \alias{nhs_pink} +\alias{nhs_emergency_red} \alias{nhs_dark_red} \alias{nhs_orange} \alias{nhs_warm_yellow} @@ -65,6 +66,8 @@ An object of class \code{character} of length 1. An object of class \code{character} of length 1. +An object of class \code{character} of length 1. + An object of class \code{character} of length 1. } \usage{ @@ -102,6 +105,8 @@ nhs_dark_pink nhs_pink +nhs_emergency_red + nhs_dark_red nhs_orange diff --git a/man/nhs_palette.Rd b/man/nhs_palette.Rd index f5ec573..0bee212 100644 --- a/man/nhs_palette.Rd +++ b/man/nhs_palette.Rd @@ -3,12 +3,17 @@ \docType{data} \name{nhs_palettes} \alias{nhs_palettes} +\alias{nhs_brewer_palettes} \title{NHS palettes} \format{ -An object of class \code{list} of length 25. +An object of class \code{list} of length 26. + +An object of class \code{list} of length 23. } \usage{ nhs_palettes + +nhs_brewer_palettes } \description{ NHS palettes @@ -16,5 +21,7 @@ NHS palettes \examples{ nhs_palettes +nhs_brewer_palettes + } \keyword{datasets} diff --git a/man/theme_acdc.Rd b/man/theme_acdc.Rd index 6366255..4d3b6b4 100644 --- a/man/theme_acdc.Rd +++ b/man/theme_acdc.Rd @@ -34,7 +34,7 @@ theme_acdc_dark( axis_title_colour = acdc_white, legend_title_colour = acdc_white, legend_text_colour = acdc_white, - plot_background_fill = tint_colour(acdc_gold, 0.2), + plot_background_fill = tint_colour(acdc_gold, 0.8), grid_col = acdc_green, grid = TRUE, axis_col = acdc_green,