Colours
Colours.Rmd
The BSOLTheme
package contains functions that return the
colours used in the Birmingham and Solihul
ICS’s branding. This Vignette will explain how to use these
functions to set the colours in plots created with ggplot2.
List available colours
To view all of the possible colours available, you can use the following function:
bsol_theme_cols()
#> green light_blue orange deep_navy purple nhs_blue
#> "#8cedab" "#4fbff0" "#fc8700" "#031d44" "#b88ce3" "#005EB8"
#> light_slate charcoal white
#> "#b2b7b9" "#2c2825" "#ffffff"
The bsol_theme_cols
function returns a named vectored of
hex-encoded RGB values of colours.
If you are only interested in specific colours, you can specify them as arguments to the function, like so:
bsol_theme_cols("orange", "light_slate", "nhs_blue")
#> orange light_slate nhs_blue
#> "#fc8700" "#b2b7b9" "#005EB8"
Or, you can use one of the available palettes:
bsol_theme_cols(palette = "main")
#> green light_blue orange deep_navy purple
#> "#8cedab" "#4fbff0" "#fc8700" "#031d44" "#b88ce3"
The documentation for bsol_theme_cols
lists all of the
palettes that are available to use.
These colours are shown below.
Using the theme with ggplot2
If you want to use the Strategy Unit’s colours in your plots, you can
use the scale_colour_bsol
and scale_fill_bsol
functions. For example, if you wish to use the main palette:
ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
geom_point() +
scale_colour_bsol()
You can also change specify a different palette, and reverse the order like so:
ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
geom_point() +
scale_colour_bsol(palette = "ics_purple", reverse = TRUE)
These functions by default are for discrete data. If you have
continuous then you need to set the discrete
argument to
FALSE
.
ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
geom_tile() +
scale_fill_bsol(discrete = FALSE, palette = "ics_orange", reverse = TRUE)