diff --git a/NEWS.md b/NEWS.md index 1a3fa05..697c9e6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # sgplot (development version) +* Add Social Security Scotland colours (`sss_colour_values`) and palettes (`sss_colour_palettes`) + # sgplot 0.2.2 * Fix links to contributing guidance in vignettes diff --git a/R/data.R b/R/data.R index 9046908..516f5c7 100644 --- a/R/data.R +++ b/R/data.R @@ -1,48 +1,48 @@ -# nolint start +# nolint: start #' @title Scottish Government colour names and hex codes #' -#' @description A vector containing colour names and their corresponding -#' hex code. +#' @description +#' * \code{sg_colour_values} is a vector containing colour names and their corresponding +#' hex codes. +#' * \code{sg_colour_palettes} is a list grouping colours into palettes. #' -#' @format A character vector #' @source \href{https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes}{Scottish Government Design System} -# nolint end +#' @md +# nolint: end "sg_colour_values" +#' @rdname sg_colour_values +"sg_colour_palettes" -# nolint start -#' @title Scottish Government colour palettes -#' -#' @description A list grouping colours into palettes. + +#' @title Social Security Scotland colour names and hex codes #' -#' @format A character list -#' @source \href{https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes}{Scottish Government Design System} -# nolint end +#' @description +#' * \code{sss_colour_values} is a vector containing colour names and their corresponding +#' hex codes. +#' * \code{sss_colour_palettes} is a list grouping colours into palettes. +#' @md -"sg_colour_palettes" +"sss_colour_values" + +#' @rdname sss_colour_values +"sss_colour_palettes" # nolint start #' @title Analysis Function colour names and hex codes #' -#' @description A vector containing colour names and their corresponding -#' hex code. +#' @description +#' * \code{af_colour_values} is a vector containing colour names and their corresponding +#' hex codes. +#' * \code{af_colour_palettes} is a list grouping colours into palettes. #' -#' @format A character vector #' @source \href{https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/}{Government Analysis Function Colours Guidance} +#' @md # nolint end "af_colour_values" - -# nolint start -#' @title Analysis Function colour palettes -#' -#' @description A list grouping colours into palettes. -#' -#' @format A character list -#' @source \href{https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/}{Government Analysis Function Colours Guidance} -# nolint end - +#' @rdname af_colour_values "af_colour_palettes" diff --git a/R/scale_colour_continuous_sg.R b/R/scale_colour_continuous_sg.R index c258a68..6f1f4cf 100644 --- a/R/scale_colour_continuous_sg.R +++ b/R/scale_colour_continuous_sg.R @@ -2,8 +2,9 @@ #' #' @param palette Name of palette to use; e.g. "main", "sequential", "focus". #' Default value is "sequential". -#' @param palette_type Either "sg" to use Scottish Government palettes, or "af" -#' to use Analysis Function palettes. Defaults to "sg". +#' @param palette_type Either `sg` to use Scottish Government palettes, `sss` +#' to use Social Security Scotland palettes or `af` to use Analysis Function +#' palettes. Defaults to `sg`. #' @param reverse Boolean value to indicate whether the palette should be #' reversed. #' @param na_colour Colour to set for missing values. @@ -20,7 +21,7 @@ #' @export scale_colour_continuous_sg <- function(palette = "sequential", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, na_colour = "grey50", guide = "colourbar", @@ -30,8 +31,9 @@ scale_colour_continuous_sg <- function(palette = "sequential", palette_list <- switch( palette_type, - af = sgplot::af_colour_palettes, - sg = sgplot::sg_colour_palettes + af = sgplot::af_colour_palettes, + sg = sgplot::sg_colour_palettes, + sss = sgplot::sss_colour_palettes ) # Error if palette doesn't exist diff --git a/R/scale_colour_discrete_sg.R b/R/scale_colour_discrete_sg.R index 1e04f4f..15ed019 100644 --- a/R/scale_colour_discrete_sg.R +++ b/R/scale_colour_discrete_sg.R @@ -2,8 +2,9 @@ #' #' @param palette Name of palette to use; e.g. "main", "sequential", "focus." #' Default value is "main". -#' @param palette_type Either "sg" to use Scottish Government palettes, or "af" -#' to use Analysis Function palettes. Defaults to "sg". +#' @param palette_type Either `sg` to use Scottish Government palettes, `sss` +#' to use Social Security Scotland palettes or `af` to use Analysis Function +#' palettes. Defaults to `sg`. #' @param reverse Boolean value to indicate whether the palette should be #' reversed. #' @param ... Additional arguments passed to scale type. @@ -21,7 +22,7 @@ #' @export scale_colour_discrete_sg <- function(palette = "main", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, ...) { diff --git a/R/scale_fill_continuous_sg.R b/R/scale_fill_continuous_sg.R index ef16e74..3a4ee59 100644 --- a/R/scale_fill_continuous_sg.R +++ b/R/scale_fill_continuous_sg.R @@ -2,8 +2,9 @@ #' #' @param palette Name of palette to use; e.g. "main", "sequential", "focus." #' Default value is "sequential". -#' @param palette_type Either "sg" to use Scottish Government palettes, or "af" -#' to use Analysis Function palettes. Defaults to "sg". +#' @param palette_type Either `sg` to use Scottish Government palettes, `sss` +#' to use Social Security Scotland palettes or `af` to use Analysis Function +#' palettes. Defaults to `sg`. #' @param reverse Boolean value to indicate whether the palette should be #' reversed. #' @param na_colour Colour to set for missing values. @@ -20,7 +21,7 @@ #' @export scale_fill_continuous_sg <- function(palette = "sequential", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, na_colour = "grey50", guide = "colourbar", @@ -30,8 +31,9 @@ scale_fill_continuous_sg <- function(palette = "sequential", palette_list <- switch( palette_type, - af = sgplot::af_colour_palettes, - sg = sgplot::sg_colour_palettes + af = sgplot::af_colour_palettes, + sg = sgplot::sg_colour_palettes, + sss = sgplot::sss_colour_palettes ) # Error if palette doesn't exist diff --git a/R/scale_fill_discrete_sg.R b/R/scale_fill_discrete_sg.R index 4cd7d37..8816d57 100644 --- a/R/scale_fill_discrete_sg.R +++ b/R/scale_fill_discrete_sg.R @@ -1,9 +1,10 @@ #' @title Discrete colour fill scales for Scottish Government plots #' #' @param palette Name of palette to use; e.g. "main", "sequential", "focus." -#' Default value is "main." -#' @param palette_type Either "sg" to use Scottish Government palettes, or "af" -#' to use Analysis Function palettes. Defaults to "sg". +#' Default value is "main". +#' @param palette_type Either `sg` to use Scottish Government palettes, `sss` +#' to use Social Security Scotland palettes or `af` to use Analysis Function +#' palettes. Defaults to `sg`. #' @param reverse Boolean value to indicate whether the palette should be #' reversed. #' @param ... Additional arguments passed to scale type. @@ -20,7 +21,7 @@ #' @export scale_fill_discrete_sg <- function(palette = "main", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, ...) { diff --git a/R/sg_palette.R b/R/sg_palette.R index fdda546..c4f8e55 100644 --- a/R/sg_palette.R +++ b/R/sg_palette.R @@ -1,26 +1,28 @@ #' Return function to use Scottish Government colour palette #' -#' @param palette Name of palette from `sg_colour_palettes` +#' @param palette Name of palette to use. #' @param reverse Boolean value to indicate whether the palette should be -#' reversed +#' reversed. #' @param colour_names Boolean value to indicate whether colour names should be -#' included -#' @param palette_type Either `sg` to use Scottish Government palettes, or `af` -#' to use Analysis Function palettes. Defaults to `sg`. +#' included. +#' @param palette_type Either `sg` to use Scottish Government palettes, `sss` +#' to use Social Security Scotland palettes or `af` to use Analysis Function +#' palettes. Defaults to `sg`. #' #' @noRd sg_palette <- function(palette = "main", reverse = FALSE, colour_names = FALSE, - palette_type = c("sg", "af")) { + palette_type = c("sg", "sss", "af")) { palette_type <- match.arg(palette_type) palette_list <- switch( palette_type, - af = sgplot::af_colour_palettes, - sg = sgplot::sg_colour_palettes + af = sgplot::af_colour_palettes, + sss = sgplot::sss_colour_palettes, + sg = sgplot::sg_colour_palettes ) # Check valid palette name diff --git a/_pkgdown.yml b/_pkgdown.yml index 61c7fb8..af95f77 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -61,13 +61,14 @@ reference: contents: - theme_sg -- title: Colours +- title: Colour scales contents: - starts_with("scale") - title: Colour values contents: - starts_with("sg_colour") + - starts_with("sss_colour") - starts_with("af_colour") - title: Helpers diff --git a/data-raw/sss_colours.R b/data-raw/sss_colours.R new file mode 100644 index 0000000..b6e87f7 --- /dev/null +++ b/data-raw/sss_colours.R @@ -0,0 +1,32 @@ +# Social Security Scotland (SSS) colours and palettes ---- + +sss_colour_values <- c( + `navy` = "#201751", + `pink` = "#ff2891", + `purple` = "#461643", + `orange` = "#e5682a", + `dark-green` = "#0b4c0b", + `green` = "#5d9f3c", + `brown` = "#592c20", + `light-pink` = "#ca72a2", + `dark-blue` = "#002d54", + `mid-blue` = "#0065bd", + `light-blue` = "#55a8f2", + `grey` = "#949494" +) + +sss_colour_palettes <- list( + `main` = sss_colour_values[c("navy", "pink", "purple", "orange")], + `main-extended` = sss_colour_values[c( + "navy", "pink", "purple", + "orange", "dark-green", "green", + "brown", "light-pink" + )], + `sequential` = sss_colour_values[c("dark-blue", "mid-blue", "light-blue")], + `focus` = sss_colour_values[c("dark-blue", "grey")] +) + +usethis::use_data(sss_colour_values, sss_colour_palettes, overwrite = TRUE) + + +### END OF SCRIPT ### diff --git a/data/sss_colour_palettes.rda b/data/sss_colour_palettes.rda new file mode 100644 index 0000000..553c69c Binary files /dev/null and b/data/sss_colour_palettes.rda differ diff --git a/data/sss_colour_values.rda b/data/sss_colour_values.rda new file mode 100644 index 0000000..b5c0d2a Binary files /dev/null and b/data/sss_colour_values.rda differ diff --git a/man/af_colour_palettes.Rd b/man/af_colour_palettes.Rd deleted file mode 100644 index f40e328..0000000 --- a/man/af_colour_palettes.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{af_colour_palettes} -\alias{af_colour_palettes} -\title{Analysis Function colour palettes} -\format{ -A character list -} -\source{ -\href{https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/}{Government Analysis Function Colours Guidance} -} -\usage{ -af_colour_palettes -} -\description{ -A list grouping colours into palettes. -} -\keyword{datasets} diff --git a/man/af_colour_values.Rd b/man/af_colour_values.Rd index 779bf5a..b3ed4ef 100644 --- a/man/af_colour_values.Rd +++ b/man/af_colour_values.Rd @@ -3,18 +3,26 @@ \docType{data} \name{af_colour_values} \alias{af_colour_values} +\alias{af_colour_palettes} \title{Analysis Function colour names and hex codes} \format{ -A character vector +An object of class \code{character} of length 9. + +An object of class \code{list} of length 5. } \source{ \href{https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/}{Government Analysis Function Colours Guidance} } \usage{ af_colour_values + +af_colour_palettes } \description{ -A vector containing colour names and their corresponding -hex code. +\itemize{ +\item \code{af_colour_values} is a vector containing colour names and their corresponding +hex codes. +\item \code{af_colour_palettes} is a list grouping colours into palettes. +} } \keyword{datasets} diff --git a/man/scale_colour_continuous_sg.Rd b/man/scale_colour_continuous_sg.Rd index d266b12..a1cb633 100644 --- a/man/scale_colour_continuous_sg.Rd +++ b/man/scale_colour_continuous_sg.Rd @@ -6,7 +6,7 @@ \usage{ scale_colour_continuous_sg( palette = "sequential", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, na_colour = "grey50", guide = "colourbar", @@ -17,8 +17,9 @@ scale_colour_continuous_sg( \item{palette}{Name of palette to use; e.g. "main", "sequential", "focus". Default value is "sequential".} -\item{palette_type}{Either "sg" to use Scottish Government palettes, or "af" -to use Analysis Function palettes. Defaults to "sg".} +\item{palette_type}{Either `sg` to use Scottish Government palettes, `sss` +to use Social Security Scotland palettes or `af` to use Analysis Function +palettes. Defaults to `sg`.} \item{reverse}{Boolean value to indicate whether the palette should be reversed.} diff --git a/man/scale_colour_discrete_sg.Rd b/man/scale_colour_discrete_sg.Rd index 6e45d85..d26c18c 100644 --- a/man/scale_colour_discrete_sg.Rd +++ b/man/scale_colour_discrete_sg.Rd @@ -6,7 +6,7 @@ \usage{ scale_colour_discrete_sg( palette = "main", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, ... ) @@ -15,8 +15,9 @@ scale_colour_discrete_sg( \item{palette}{Name of palette to use; e.g. "main", "sequential", "focus." Default value is "main".} -\item{palette_type}{Either "sg" to use Scottish Government palettes, or "af" -to use Analysis Function palettes. Defaults to "sg".} +\item{palette_type}{Either `sg` to use Scottish Government palettes, `sss` +to use Social Security Scotland palettes or `af` to use Analysis Function +palettes. Defaults to `sg`.} \item{reverse}{Boolean value to indicate whether the palette should be reversed.} diff --git a/man/scale_fill_continuous_sg.Rd b/man/scale_fill_continuous_sg.Rd index 77b2389..964908b 100644 --- a/man/scale_fill_continuous_sg.Rd +++ b/man/scale_fill_continuous_sg.Rd @@ -6,7 +6,7 @@ \usage{ scale_fill_continuous_sg( palette = "sequential", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, na_colour = "grey50", guide = "colourbar", @@ -17,8 +17,9 @@ scale_fill_continuous_sg( \item{palette}{Name of palette to use; e.g. "main", "sequential", "focus." Default value is "sequential".} -\item{palette_type}{Either "sg" to use Scottish Government palettes, or "af" -to use Analysis Function palettes. Defaults to "sg".} +\item{palette_type}{Either `sg` to use Scottish Government palettes, `sss` +to use Social Security Scotland palettes or `af` to use Analysis Function +palettes. Defaults to `sg`.} \item{reverse}{Boolean value to indicate whether the palette should be reversed.} diff --git a/man/scale_fill_discrete_sg.Rd b/man/scale_fill_discrete_sg.Rd index 8010194..f1af433 100644 --- a/man/scale_fill_discrete_sg.Rd +++ b/man/scale_fill_discrete_sg.Rd @@ -6,17 +6,18 @@ \usage{ scale_fill_discrete_sg( palette = "main", - palette_type = c("sg", "af"), + palette_type = c("sg", "sss", "af"), reverse = FALSE, ... ) } \arguments{ \item{palette}{Name of palette to use; e.g. "main", "sequential", "focus." -Default value is "main."} +Default value is "main".} -\item{palette_type}{Either "sg" to use Scottish Government palettes, or "af" -to use Analysis Function palettes. Defaults to "sg".} +\item{palette_type}{Either `sg` to use Scottish Government palettes, `sss` +to use Social Security Scotland palettes or `af` to use Analysis Function +palettes. Defaults to `sg`.} \item{reverse}{Boolean value to indicate whether the palette should be reversed.} diff --git a/man/sg_colour_palettes.Rd b/man/sg_colour_palettes.Rd deleted file mode 100644 index 4b2295b..0000000 --- a/man/sg_colour_palettes.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{sg_colour_palettes} -\alias{sg_colour_palettes} -\title{Scottish Government colour palettes} -\format{ -A character list -} -\source{ -\href{https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes}{Scottish Government Design System} -} -\usage{ -sg_colour_palettes -} -\description{ -A list grouping colours into palettes. -} -\keyword{datasets} diff --git a/man/sg_colour_values.Rd b/man/sg_colour_values.Rd index ac8993c..87bbc1e 100644 --- a/man/sg_colour_values.Rd +++ b/man/sg_colour_values.Rd @@ -3,18 +3,26 @@ \docType{data} \name{sg_colour_values} \alias{sg_colour_values} +\alias{sg_colour_palettes} \title{Scottish Government colour names and hex codes} \format{ -A character vector +An object of class \code{character} of length 11. + +An object of class \code{list} of length 4. } \source{ \href{https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes}{Scottish Government Design System} } \usage{ sg_colour_values + +sg_colour_palettes } \description{ -A vector containing colour names and their corresponding -hex code. +\itemize{ +\item \code{sg_colour_values} is a vector containing colour names and their corresponding +hex codes. +\item \code{sg_colour_palettes} is a list grouping colours into palettes. +} } \keyword{datasets} diff --git a/man/sss_colour_values.Rd b/man/sss_colour_values.Rd new file mode 100644 index 0000000..54d72e7 --- /dev/null +++ b/man/sss_colour_values.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{sss_colour_values} +\alias{sss_colour_values} +\alias{sss_colour_palettes} +\title{Social Security Scotland colour names and hex codes} +\format{ +An object of class \code{character} of length 12. + +An object of class \code{list} of length 4. +} +\usage{ +sss_colour_values + +sss_colour_palettes +} +\description{ +\itemize{ +\item \code{sss_colour_values} is a vector containing colour names and their corresponding +hex codes. +\item \code{sss_colour_palettes} is a list grouping colours into palettes. +} +} +\keyword{datasets} diff --git a/vignettes/colours.Rmd b/vignettes/colours.Rmd index a470550..54ae650 100644 --- a/vignettes/colours.Rmd +++ b/vignettes/colours.Rmd @@ -25,10 +25,12 @@ table_note <- paste( ) ``` -sgplot provides colour palettes as set out by the [Scottish Government Design System](https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes). +sgplot provides [Scottish Government branded colour palettes](#sg) as set out by the [Scottish Government Design System](https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes). These palettes have been developed to meet the [Web Content Accessibility Guidelines 2.1 for graphical objects](https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html). The colours in the [main palette for categorical data](#main-palette) all have at least a 3:1 colour contrast ratio with white (#ffffff) and off-white (#f8f8f8) backgrounds, as well as with adjacent colours in the palette. +In addition to the default [Scottish Government palettes](#sg), sgplot also supports the use of branded palettes for [Social Security Scotland](#sss) and the [Government Analysis Function](#af). + ## Things to consider when using colour @@ -49,11 +51,13 @@ The following are a few key things to consider when using colour in data visuali * Use colour palettes in the order presented to ensure adjacent colours have sufficient contrast with each other -## Scottish Government colour palettes +## Colour palettes in sgplot + +### Scottish Government {#sg} The Scottish Government colour palettes are used by default in sgplot. -### Main palette +#### Main palette The `main` palette should be used with categorical data. @@ -72,7 +76,7 @@ sgplot:::colour_table(sgplot::sg_colour_palettes$`main-extended`) ``` -### Sequential palette +#### Sequential palette {#sg-sequential} The `sequential` colour palette should be used for data where the order has some meaning. @@ -87,7 +91,7 @@ Neither `dark-blue` or `light-blue` have sufficient colour contrast with `mid-bl Follow the [advice for using the sequential palette](https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-6) in the Analysis Function colour guidance when using this palette. -### Focus palette +#### Focus palette {#sg-focus} The `focus` palette should be used to highlight specific elements of a plot. @@ -100,12 +104,63 @@ sgplot:::colour_table(sgplot::sg_colour_palettes$focus) The `grey` in this palette does not meet the required colour contrast with an off-white background (#f8f8f8), therefore charts using this palette should only use a white background (#ffffff). -## Analysis Function colour palettes +### Social Security Scotland {#sss} + +To use a Social Security Scotland palette, set `palette_type = "sss"` when using any of the `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colour-scales). + +#### Main palette + +The `main` palette should be used with categorical data. + +`r table_note` + +```{r} +sgplot:::colour_table(sgplot::sss_colour_palettes$main) +``` + +You should try to use an absolute maximum of four colours in a chart. If you feel you need more than four, think about how you could redesign your chart to avoid this. If you absolutely must use more than four colours, the `main-extended` palette can be used. + +`r table_note` -The Analysis Function guidance also contains [suggested colour palettes](https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-4). These are also provided in sgplot, however the Scottish Government palettes are used by default. To use an Analysis Function palette, set `palette_type = "af"` when using any of the `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colours). +```{r} +sgplot:::colour_table(sgplot::sss_colour_palettes$`main-extended`) +``` -### Main palette +#### Sequential palette + +The `sequential` colour palette should be used for data where the order has some meaning. This palette is the same as the [Scottish Government sequential palette](#sg-sequential). + +`r table_note` + +```{r} +sgplot:::colour_table(sgplot::sss_colour_palettes$sequential) +``` + +As this palette is restricted to tints of one colour, there are issues with colour contrast. +Neither `dark-blue` or `light-blue` have sufficient colour contrast with `mid-blue`. +Follow the [advice for using the sequential palette](https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-6) in the Analysis Function colour guidance when using this palette. + + +#### Focus palette + +The `focus` palette should be used to highlight specific elements of a plot.This palette is the same as the [Scottish Government focus palette](#sg-focus). + +`r table_note` + +```{r} +sgplot:::colour_table(sgplot::sss_colour_palettes$focus) +``` + +The `grey` in this palette does not meet the required colour contrast with an off-white background (#f8f8f8), therefore charts using this palette should only use a white background (#ffffff). + + +### Government Analysis Function {#af} + +The Government Analysis Function guidance also contains [suggested colour palettes](https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-4). These are also provided in sgplot, however the Scottish Government palettes are used by default. To use an Analysis Function palette, set `palette_type = "af"` when using any of the `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colour-scales). + + +#### Main palette The `main` palette should be used with categorical data. @@ -133,7 +188,7 @@ sgplot:::colour_table(sgplot::af_colour_palettes$main6) ``` -### Sequential palette +#### Sequential palette The `sequential` colour palette should be used for data where the order has some meaning. @@ -147,7 +202,7 @@ As this palette is restricted to tints of one colour, there are issues with colo Follow the [advice for using the sequential palette](https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/#section-6) in the Analysis Function colour guidance when using this palette. -### Focus palette +#### Focus palette The `focus` palette should be used to highlight specific elements of a plot. @@ -173,7 +228,7 @@ An example of how to use an alternative colour palette is provided in the [cookb However, if you use a different palette regularly and feel it would be useful for this to be added to sgplot, please make a suggestion as per the [contributing guidance](https://scotgovanalysis.github.io/sgplot/CONTRIBUTING.html). -## Viewing Palettes in R +## Viewing palettes in R Names and hex codes for available colours and palettes can be viewed by running the following code: @@ -187,8 +242,11 @@ sgplot::sg_colour_palettes # View names and hex codes for `main` colour palette sgplot::sg_colour_palettes$main +# For Social Security Scotland palettes, use the sss_ prefix +sgplot::sss_colour_palettes + # For Analysis Function palettes, use the af_ prefix sgplot::af_colour_palettes ``` -Examples of how to apply these palettes to ggplot2 charts are available in both the [cookbook](https://scotgovanalysis.github.io/sgplot/articles/cookbook.html) and the reference files for `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colours). +Examples of how to apply these palettes to ggplot2 charts are available in both the [cookbook](https://scotgovanalysis.github.io/sgplot/articles/cookbook.html) and the reference files for `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colour-scales). diff --git a/vignettes/cookbook/_colour-palettes.Rmd b/vignettes/cookbook/_colour-palettes.Rmd index 24ec256..d7affa5 100644 --- a/vignettes/cookbook/_colour-palettes.Rmd +++ b/vignettes/cookbook/_colour-palettes.Rmd @@ -43,7 +43,7 @@ gapminder |> Note: This chart is for demonstration purposes only. Accessibility guidance recommends using a maximum of four colours to avoid clutter. -To use an Analysis Function palette, set `palette_type = "af"` when using any of the `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colours). +To use an Analysis Function palette, set `palette_type = "af"` when using any of the `scale_` [colour functions](https://scotgovanalysis.github.io/sgplot/reference/index.html#colour-scales). For example, to use the Analysis Function `main2` palette: ```{r af-palette, fig.height = 5}