-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
262 lines (189 loc) · 8.18 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "80%"
)
asciicast::init_knitr_engine(
startup = quote({
library(DoHACpalette)
set.seed(1) }),
echo = TRUE,
echo_input = FALSE
)
```
# dohactheme
<!-- badges: start -->
<!-- badges: end -->
The Department of Health and Aged Care's colours play an important role in the
Department’s identity.
The main purpose of dohactheme is to enable R users in Australian public policy to use the colours and styles defined in DoHAC's Style Sheet to create compliant visualisation in ggplot.
dohactheme was created with the **palettes** package, which provides a comprehensive library for colour vectors and colour palettes using a new family of colour classes (`palettes_colour`, and `palettes_palette`) that always print as hex codes with colour previews. Colour palette packages created with palettes have access to the following capabilities, all without requiring you to write any code: formatting, casting and coercion, extraction and updating of components, plotting, colour mixing arithmetic, and colour interpolation.
See the following vignettes to learn how to use palletes with other packages:
- [Using palettes with ggplot2](https://mccarthy-m-g.github.io/palettes/articles/ggplot2.html)
- [Using palettes with gt](https://mccarthy-m-g.github.io/palettes/articles/gt.html)
- [Using palettes with biscale](https://mccarthy-m-g.github.io/palettes/articles/biscale.html)
- [Compatibility with other colour packages](https://mccarthy-m-g.github.io/palettes/articles/compatibility.html)
## Included Colours
### Primary colours
DoHAC's primary colour palette comprises blue and teal, with a secondary dark shade of both.
### DoHAC blue and dark blue
```{r blues, echo=FALSE, out.height="30px",out.width="120px"}
library(dohactheme)
plot(c(dohac.blue,dohac.darkblue))
```
### DoHAC teal and dark teal
```{r teals, echo=FALSE, out.height="30px",out.width="120px"}
plot(c(dohac.teal,dohac.darkteal))
```
## Secondary colours
DoHAC's secondary colours `dohac_colours$secondary` add further shades of blue and teal, as well as pink and orange.
```{r secondary, echo=FALSE, out.height="30px",out.width="120px"}
plot(c(dohac_colours$secondary))
```
## Secondary tints
DoHAC's secondary colours are complemented by a series of tints `dohac_colours$tints` of the same colours.
```{r secondary_tints,echo=FALSE, out.height="30px",out.width="120px"}
plot(c(dohac_colours$tints))
```
## Neutrals
DoHAC's neutral colours are a series of 5 grey shades `dohac_colours$neutrals` .
```{r neutrals,echo=FALSE, out.height="30px",out.width="120px"}
plot(c(dohac_colours$neutrals))
```
## Accents
DoHAC's accents colours `dohac_colours$accents` are red and yellow.
```{r accents,echo=FALSE, out.height="30px",out.width="120px"}
plot(c(dohac_colours$accents))
```
## Accessible
DoHAC's brand palettes can be hard to differentiate when used individually in charts and other infographics. We have chosen a selection of colours with higher contrast and grouped them as `dohac_colours$accessible`. This palette is subject to revision based on feedback and testing
```{r accessible, echo=FALSE, out.height="30px",out.width="120px"}
plot(c(dohac_colours$accessible))
```
## Installation
You can install the development version of DoHACpalette from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("zerogetsamgow/dohactheme")
```
## Usage
```{r usage_setup, include = FALSE, echo=FALSE, output=FALSE}
library(ggplot2)
library(tidyverse,verbose = FALSE, warn.conflicts = FALSE)
library(stringr)
```
{dohactheme} is designed to produce {gglot2} that comply with the DoHAC style guide simply. For example.
```{r white_example, warnings=FALSE}
## basic example code
ggplot2::ggplot(data=iris,aes(x=Sepal.Length, y = Petal.Length,colour=Species)) +
geom_point(size=3) +
scale_colour_manual(values=dohac_colours$primary,labels=stringr::str_to_title) +
scale_x_continuous(name="Sepal length")+
scale_y_continuous(name="Petal length")+
theme_dohac_white()
```
{dohactheme} exports two themes - `theme_dohac_white()`(seen above) and `theme_dohac_blue()` to enable plots to be produced for any DoHAC publication.
```{r blue_example, warnings = FALSE}
## basic example of a green plot
ggplot(data=iris,aes(x=Sepal.Length, y = Petal.Length,colour=Species)) +
geom_point(size=3) +
scale_colour_manual(values=dohac_colours$secondary,labels=stringr::str_to_title) +
scale_x_continuous(name="Sepal length")+
scale_y_continuous(name="Petal length")+
labs(title="Sepal and petal lengths of irises")+
theme_dohac_blue()
```
As well as utilising DoHAC coloutes these themes are rendered using the `Helvetica neue` font.
## Maps
{dohactheme} exports a theme - `theme_dohac_map()` to be used when plotting maps. This theme can be produced with white or blue backgrounds. White is the default.
```{r map_prep, echo=FALSE, warnings = FALSE}
library(sf)
library(strayr)
```
```{r map_grey, warnings = FALSE}
## basic example of a map with grey background
ggplot(
data =
strayr::read_absmap(
name="state2021",
remove_year_suffix = TRUE
) |>
filter(state_name %in% strayr::state_name_au) |>
mutate(state_name =
factor(
state_name,
levels=strayr::state_name_au)
),
aes(fill=state_name, x=cent_long, y =cent_lat, label = str_wrap(state_name,10))) +
geom_sf() +
geom_text(colour = dohac.blue, lineheight=.5)+
scale_fill_manual(guide='none',values=colorspace::lighten(strayr::palette_state_name_2016,.7)) +
labs(title="Australia's States and Territories")+
theme_dohac_map(base_colour = "white", base_size = 10)
```
```{r map_blue, warnings = FALSE}
## basic example of a map with grey background
ggplot(
data =
strayr::read_absmap(
name="state2021",
remove_year_suffix = TRUE
) |>
filter(state_name %in% strayr::state_name_au) |>
mutate(state_name =
factor(
state_name,
levels=strayr::state_name_au)
),
aes(fill=state_name, x=cent_long, y =cent_lat, label = str_wrap(state_name,10))) +
geom_sf() +
geom_text(colour = dohactheme::dohac.lightteal, lineheight=.5)+
scale_fill_manual(guide='none',values=colorspace::lighten(strayr::palette_state_name_2016,.2)) +
labs(title="Australia's States and Territories")+
theme_dohac_map(base_colour = "blue", base_size = 10)
```
DoHAC palette comes with a set of `r length(dohac_colours)` discrete colour palettes, and `r length(dohac_palettes) - length(dohac_colours) ` sequential colour palettes, which can be accessed from the following R objects:
- `dohac_colours` for discrete palettes
- `dohac_palettes` for discrete and sequential palettes
### Discrete
Discrete palettes matching the above groups - `primary`, `secondary`, `tints`,`neutrals` and `accents`.
```{r plot-DoHAC-palettes-discrete}
plot(dohac_colours[1:5])
```
### Tints
For long form documents infographics and charts, tints from the DoHAC colour palette can be used in 20 per cent increments. `dohac_palettes$blues` and `dohac_palettes$teals` are populated with compliant `blue` and `teal` shades.
```{r plot-DoHAC-palettes-tints}
plot(dohac_colours)
```
Palettes can be subset using `[`, `[[`, and `$`.
- To extract one or more palettes use `[`:
```{r extract-palette}
plot(dohac_palettes[c("primary", "accents")])
```
- To extract a single palette as a colour vector use `[[` or `$`:
```{r extract-vector-1}
plot(dohac_palettes[["teals"]])
```
```{r extract-vector-2}
plot(dohac_palettes$blues)
```
- To get names of palettes use `names()`:
```{r}
names(dohac_palettes)
```
## Documentation
See also documentation for the palettes package at [`https://mccarthy-m-g.github.io/palettes/`](https://mccarthy-m-g.github.io/palettes/reference/index.html) or in the installed package: `help(package = "palettes")`.