This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
158 lines (122 loc) · 4.78 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "tools/README-"
)
```
# DHSC Colours R package
## 🚨 Deprecation Notice 🚨
This repository is **deprecated** as of 17 October 2024. It is no longer actively maintained.
For similar functionality, please refer to [afcolours](https://github.com/best-practice-and-impact/afcolours).
## Features
- DHSC branded powerpoint template for rmarkdown.
- Approved colour codes for DHSC outputs.
- Colourblind friendly options
- ggplot theme for consistant outputs
- ggplot fill and colour scales using dhsc branding colours.
- Shortcut function remove y axis padding so intercept can be 0.
- DHSC_table function for left aligned tables in markdown.
## Installation
Install using remotes:
```{r install, eval=FALSE}
remotes::install_github("https://github.com/DataS-DHSC/DHSC_colours")
```
## Branded powerpoint template
Installing this package will install the template for a DHSC
branded powerpoint in rmarkdown. Accessed from within rstudio via:
*File > New File > R Markdown > From Template > DHSC Powerpoint*
## Colour Codes
The function ```dhsc_colours()``` will return a named list of the approved
colours. Each individual colour can also be called by it's helper function.
For example: ```dhsc_dark_blue()```. There are approved shades of black, white
and grey, which are retrieved via ```dhsc_bw()```
Having access to the individual colour codes like this will allow users to quickly
format whatever vizualisation library they are using to align with the DHSC palette.
## Colourblind friendly palettes
Three and four colour accesible pallets have been hard coded into this package.
You can retrieve the colour selections with ```DHSC_accessible_3()``` and
```DHSC_accessible_4()```. Or you can use them directly with your ggplots via
```DHSC_accessible_scales()```.
## ggplot theme
There is a ggplot theme which you can include with any ggplot to standardise on a
consistant aesthetic. The theme is accessed via ```theme_dhsc()``` and can be
included in any ggplot with ```+theme_dhsc()```
## ggplot colour and fill scales
There are also some colour scales which you can ```+``` on to a ggplot object
to recolour it with DHSC colours. There are separate scales for continuous and discrete variables.
## Shortcut to set y axis intercept to 0.
By default, ggplot adds a 5% padding to your data when creating a y axis, this is
to ensure that your data don't sit directly on the axis line. However it is not
always desirable, e.g. with bar plots. Adding ```+zero_y_padding()``` to your
ggplot objects will remove the padding, improving the way some plots appear.
## DHSC tables
By default, numeric columns in rmarkdown can appear right aligned (excel style).
The ```DHSC_table()``` function removes this behaviour and aligns all table text
to the left.
## Example Plots
```{r examples, message=FALSE}
library(dplyr)
library(ggplot2)
library(DHSCcolours)
# Barplot with 3 bars with a discrete X axis filled with DHSC colours
sim_series(3) %>%
ggplot(aes(x = X, y = Z, fill = X)) +
geom_col() +
DHSCcolours::scale_fill_dhsc_d() +
theme_dhsc() +
ggtitle("scale_fill_dhsc_d") +
zero_y_padding()
# Barplot with 4 bars with a discrete X axis filled with accesible colours
sim_series(4) %>%
ggplot(aes(x = X, y = Z, fill = X)) +
geom_col() +
DHSCcolours::DHSC_accessible_scales(4) +
theme_dhsc() +
ggtitle("scale_fill_dhsc_d") +
zero_y_padding()
# Barplot with 25 bars with a discrete X axis filled with DHSC colours
sim_series(25) %>%
ggplot(aes(x = X, y = Z, fill = X)) +
geom_col() +
DHSCcolours::scale_fill_dhsc_d() +
theme_dhsc() +
ggtitle("scale_fill_dhsc_d") +
zero_y_padding()
# Barplot with 25 bars with a continuous X axis with DHSC primary green - purple fill
sim_series(25) %>%
ggplot(aes(x = Y, y = Z, fill = Z)) +
geom_col() +
scale_fill_dhsc_c() +
theme_dhsc() +
ggtitle("scale_fill_dhsc_c") +
zero_y_padding()
# Barplot with 25 bars with a continuous X axis with red green fill
sim_series(25) %>%
ggplot(aes(x = Y, y = Z, fill = Z)) +
geom_col() +
scale_fill_dhsc_red_green_c() +
theme_dhsc() +
ggtitle("scale_fill_dhsc_red_green_c") +
zero_y_padding()
# Barplot with 25 bars with a continuous X axis with blue green fill
sim_series(25) %>%
ggplot(aes(x = Y, y = Z, fill = Z)) +
geom_col() +
scale_fill_dhsc_blue_green_c() +
theme_dhsc() +
ggtitle("scale_fill_dhsc_blue_green_c") +
zero_y_padding()
# Barplot with 25 bars with a continuous X axis with blue yellow fill
sim_series(25) %>%
ggplot(aes(x = Y, y = Z, fill = Z)) +
geom_col() +
scale_fill_dhsc_blue_yellow_c() +
theme_dhsc() +
ggtitle("scale_fill_dhsc_blue_yellow_c") +
zero_y_padding()
```