Skip to content

Commit

Permalink
Restructure colours vignette and update links to colour scales reference
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-hannah committed Oct 28, 2024
1 parent 067ec67 commit 9df2254
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions vignettes/colours.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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).

Expand All @@ -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).

Expand All @@ -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.

Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -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:

Expand All @@ -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).
2 changes: 1 addition & 1 deletion vignettes/cookbook/_colour-palettes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 9df2254

Please sign in to comment.