-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
139 lines (111 loc) · 3.92 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
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- 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 = "75%",
fig.retina = 2
)
```
# djprtheme
<!-- badges: start -->
[![R-CMD-check](https://github.com/djpr-data/djprtheme/workflows/R-CMD-check/badge.svg)](https://github.com/djpr-data/djprtheme/actions)
[![Codecov test coverage](https://codecov.io/gh/djpr-data/djprtheme/branch/main/graph/badge.svg)](https://codecov.io/gh/djpr-data/djprtheme?branch=main)
[![Lifecycle: superseded](https://img.shields.io/badge/lifecycle-superseded-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#superseded)
<!-- badges: end -->
**This package is under active development**
The goal of `djprtheme` is to enable users to easily create ggplot2 charts that look good and are consistent with the style guide of the Victorian Department of Jobs, Precincts and Regions.
## Installation
You can install `djprtheme` from [GitHub](https://github.com/) with:
```{r eval = FALSE}
# install.packages("devtools")
devtools::install_github("djsir-data/djprtheme")
```
## The DJPR palette
```{r colours, echo=FALSE, include=FALSE}
devtools::load_all()
library(ggplot2)
col_names <- c("djpr_cobalt",
"djpr_bondi_blue",
"djpr_lima",
"djpr_electric_lime",
"djr_royal_blue",
"djpr_green",
"djpr_persimmon",
"djpr_dark_tangerine",
"djpr_black_rock",
"djpr_cool_grey_11",
"djpr_cool_grey_1")
cols <- c(djpr_cobalt,
djpr_bondi_blue,
djpr_lima,
djpr_electric_lime,
djpr_royal_blue,
djpr_green,
djpr_persimmon,
djpr_dark_tangerine,
djpr_black_rock,
djpr_cool_grey_11,
djpr_cool_grey_1)
df <- data.frame(col = cols,
name = col_names)
ggplot(df,
aes(x = factor(name,
levels = rev(name)),
y = 1,
fill = name)) +
geom_tile() +
geom_text(aes(label = col),
col = "white") +
coord_flip() +
scale_fill_manual(values = cols) +
theme_void() +
theme(axis.text.y = element_text(hjust = 1),
legend.position = "none")
```
You can style your plots with the DJPR palette using the `djpr_colour_manual()` and `djpr_fill_manual()` functions. You should specify the number of colours in your plot. These are the colours that will be used in your plot:
```{r palette-pyramid, echo=FALSE, warning=FALSE}
make_col_tibble <- function(n) {
dplyr::tibble(col = suppressWarnings(djpr_pal(n)),
order = c(1:n),
n = n)
}
djpr_colours <- lapply(c(1:10), make_col_tibble) %>%
dplyr::bind_rows()
djpr_colours$col <- factor(djpr_colours$col)
djpr_colours <- djpr_colours %>%
dplyr::mutate(n_desc = dplyr::if_else(n == 1, "n = 1", paste0(" ", n)))
col_plot <- djpr_colours %>%
ggplot(aes(x = reorder(n_desc, -n),
y = order,
fill = col)) +
geom_tile(col = "white", size = 1) +
scale_fill_manual(values = levels(djpr_colours$col)) +
coord_flip(expand = FALSE, ylim = c(0, 13)) +
theme_djpr() +
theme(panel.grid = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank(),
axis.line = element_blank(),
axis.text.x = element_blank(),
legend.position = "none") +
labs(title = "These are the colours of the DJPR palette")
col_plot
```
The hex codes for those colours are:
```{r palette-hex-codes, echo = FALSE, warning = FALSE}
hexes <- suppressWarnings(djpr_pal(10))
hex_df <- data.frame(hex = hexes,
row = -seq_along(hexes))
ggplot(hex_df, aes(y = row, fill = hex, label = hex, x = 1)) +
geom_tile() +
geom_text(aes(label = hex), colour = "white") +
scale_fill_identity() +
theme_void()
```