From 9df2254638c3ed005a11db4c6c365c7225426943 Mon Sep 17 00:00:00 2001 From: alice-hannah Date: Mon, 28 Oct 2024 13:05:22 +0000 Subject: [PATCH] Restructure colours vignette and update links to colour scales reference --- vignettes/colours.Rmd | 34 +++++++++++++------------ vignettes/cookbook/_colour-palettes.Rmd | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/vignettes/colours.Rmd b/vignettes/colours.Rmd index d4ed9fd..54ae650 100644 --- a/vignettes/colours.Rmd +++ b/vignettes/colours.Rmd @@ -51,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 {#sg} +## 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. @@ -74,7 +76,7 @@ sgplot:::colour_table(sgplot::sg_colour_palettes$`main-extended`) ``` -### Sequential palette {#sg-sequential} +#### Sequential palette {#sg-sequential} The `sequential` colour palette should be used for data where the order has some meaning. @@ -89,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 {#sg-focus} +#### Focus palette {#sg-focus} The `focus` palette should be used to highlight specific elements of a plot. @@ -102,11 +104,11 @@ 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). -## Social Security Scotland colour palettes {#sss} +### 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#colours). +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 +#### Main palette The `main` palette should be used with categorical data. @@ -125,7 +127,7 @@ sgplot:::colour_table(sgplot::sss_colour_palettes$`main-extended`) ``` -### Sequential 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). @@ -140,7 +142,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 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). @@ -153,12 +155,12 @@ 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). -## Analysis Function colour palettes {#af} +### Government Analysis Function {#af} -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). +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 +#### Main palette The `main` palette should be used with categorical data. @@ -186,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. @@ -200,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. @@ -226,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: @@ -247,4 +249,4 @@ sgplot::sss_colour_palettes 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}