-
Notifications
You must be signed in to change notification settings - Fork 0
/
RISE_theme.R
67 lines (62 loc) · 2.52 KB
/
RISE_theme.R
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
### set up color palette based on RISE guidelines
RISEprimGreen <- "#009ca6"
RISEprimRed <- "#e83c63"
RISEprimYellow <- "#ffe500"
RISEprimGreenMid <- "#8dc8c7"
RISEprimRedMid <- "#f5a9ab"
RISEprimYellowMid <- "#ffee8d"
RISEprimGreenLight <- "#ebf5f0"
RISEprimRedLight <- "#fde8df"
RISEprimYellowLight <- "#fff7dd"
RISEcompPurple <- "#482d55"
RISEcompGreenDark <- "#0e4e65"
RISEgrey1 <- "#f0f0f0"
RISEgrey2 <- "#c8c8c8"
RISEgrey3 <- "#828282"
RISEgrey4 <- "#555555"
# ggplot theme
theme_rise <- function(fontfamily = "Lato", axissize = 13, titlesize = 15,
margins = 12, axisface = "plain", panelDist = 0.6, ...) {
theme_minimal() +
theme(
text = element_text(family = fontfamily),
axis.title.x = element_text(
margin = margin(t = margins),
size = axissize
),
axis.title.y = element_text(
margin = margin(r = margins),
size = axissize
),
plot.title = element_text(
face = "bold",
size = titlesize
),
axis.title = element_text(
face = axisface
),
plot.caption = element_text(
face = "italic"
),
legend.text = element_text(family = fontfamily),
legend.background = element_rect(color = "lightgrey"),
strip.background = element_rect(color = "lightgrey"),
panel.spacing = unit(panelDist, "cm", data = NULL),
panel.border = element_rect(color = "grey", fill = NA),
...
)
}
# set theme as default for the session/document
theme_set(theme_rise())
### RISE color palettes
# the two palettes below have been checked for color blindness compatibility using library(colorblindcheck)
RISEpalette8 <- c("#009CA6", "#428092", "#84657F", "#C6496C", "#EB5454", "#F18438", "#F8B41C", "#FFE500")
RISEpalette6 <- c("#009CA6", "#5C758B", "#B94F70", "#EC5D4F", "#F5A127", "#FFE500")
### palettes can be created using the three RISE primary colors and changing the number at the end:
# RISEpalette1 <- colorRampPalette(colors = c("#009ca6", "#e83c63", "#ffe500"))(6)
# palettes are used with for example `+ scale_color_manual(values = RISEpalette6, aesthetics = c("fill", "color"))
# gender split colors, replace label based on your dataset
gender_colors <- c("Male" = "#F5A127", "Female" = "#009CA6")
# these can be used in ggplots as `+ scale_color_gender()` or `+ scale_fill_gender()`
scale_color_gender <- partial(scale_color_manual, values = gender_colors)
scale_fill_gender <- partial(scale_fill_manual, values = gender_colors)