-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
196 lines (145 loc) · 3.51 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
---
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-",
fig.height = 1,
out.width = "100%"
)
```
# idpalette
Palettes based on the colour schemes for [IDEM](https://www.telethonkids.org.au/our-research/brain-and-behaviour/child-health-analytics-research-program/infectious-disease-ecology-and-modelling/),
[IDDU](https://mspgh.unimelb.edu.au/research-groups/centre-for-epidemiology-and-biostatistics-research/infectious-disease-dynamics), and [ACEFA](https://acefa-hubs.github.io)
<!-- badges: start -->
[![R-CMD-check](https://github.com/idem-lab/idpalette/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/idem-lab/idpalette/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/idem-lab/idpalette/graph/badge.svg)](https://app.codecov.io/gh/idem-lab/idpalette)
<!-- badges: end -->
## Installation
You can install the development version of `idpalette` from
[GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("idem-lab/idpalette")
```
### Python friend
There is a python version of `idpalette` also on [GotHyb](https://github.com/)
by Rob Moss:
[https://github.com/robmoss/idpalette](https://github.com/robmoss/idpalette)
## Using `idpalette`
The function `idpalette` takes arguments:
- `p`, the palette, i.e., `"idem"`, `"iddu"`, or `"acefa"`, and
- `n`, number of colours needed.
These can also be accessed by alias functions for each palette: `idem(n)`,
`iddu(n)`, and `acefa(n)`
If `n` is not specified, the default is the number of colours in the true base
palette, i.e., 7 for IDEM, and 5 for IDDU and ACEFA.
Usage per above calls palettes based on the colours in the group logos. There
are also "official" versions of the palettes, which contain only the four
colours specifically selected for use by the graphic design team.
## Main colours
### IDEM
```{r}
library(idpalette)
idpalette("idem")
```
```{r}
idpalette("idem_official")
```
### IDDU
```{r}
idpalette("iddu")
```
```{r}
idpalette("iddu_official")
```
### ACEFA
```{r}
idpalette("acefa")
```
```{r}
idpalette("acefa_official")
```
## Alias functions
```{r}
idem()
```
```{r}
iddu()
```
```{r}
acefa()
```
## Your colours your way
As many or as few colours as you want, forwards or backwards.
```{r}
idpalette("iddu", 20)
```
```{r}
idpalette("acefa", 2)
```
```{r}
idem(10, rev = TRUE)
```
## Have a go ya mug
```{r, fig.height= 4}
library(ggplot2)
ggplot(
faithfuld,
aes(waiting, eruptions)
) +
geom_raster(
aes(fill = density)
) +
scale_fill_gradientn(
colours = idpalette("iddu", 100)
)
```
```{r fig.height= 4}
ggplot(mpg) +
geom_bar(
aes(
x = trans,
fill = class
)
) +
scale_fill_manual(values = idpalette("idem")) +
theme_bw()
```
Works with `terra` plotting:
```{r, fig.height=4}
library(sdmtools)
library(terra)
r <- example_raster(seed = 20240802)
par(mfcol = c(1, 2))
plot(
r,
col = idem(100)
)
plot(
r,
col = idem(100, rev = TRUE)
)
```
Sometimes `ggplot2` won't play nicely being fed a vector of values for
continuous scales, so `scale_id_continuous` allows `idpalette` or any arbitrary
vector of colours to be used:
```{r, fig.height= 4}
library(ggplot2)
ggplot(mtcars) +
geom_point(
aes(
x = disp,
y = hp,
colour = qsec
),
size = 5
) +
scale_id_continuous(
cols = iddu(),
aesthetics = "colour"
)
```