knitr::opts_chunk$set( echo = TRUE, collapse = TRUE, out.width = "100%")
Provides R functions and templates for plotting and reporting analyses using DGI Clinical company colours.
# install.package("devtools") remotes::install_github("taylordunn/dgitheme")
Reference the documentation with ?dgi_pal
, ?dgi_colors
and ?scale_color_dgi
.
To visualize the color palettes:
scales::show_col(dgi_pal()(3)) scales::show_col(dgi_pal("official")(6))
To return the character hex codes as a vector:
dgi_colors("teal") ggplot(mtcars, aes(hp, mpg, color = factor(cyl))) + geom_point(size = 4) + scale_color_manual(values = dgi_colors("teal", "light grey", "black")) + theme_minimal()
There are also convenience ggplot2
scale functions:
ggplot(mtcars, aes(hp, mpg, color = factor(cyl))) + geom_point(size = 4) + scale_color_dgi() + theme_minimal()
To create a new RMarkdown document with useful defaults: File -> New File -> R Markdown -> From Template -> DGI RMarkdown Report Template.
library(tidyverse) library(patchwork) palette_plots <- tibble( palette = c("main", "cool", "grey", "official", "teal white", "teal black", "teal grey", "blue white", "blue black", "blue grey", "sea green white", "sea green black", "sea green grey", "complementary", "split-complementary", "triadic", "tetradic", "qualitative"), n = c(3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 3, 4, 5) ) %>% mutate(colors = map2(palette, n, ~dgitheme::dgi_pal(.x)(.y))) %>% unnest(colors) %>% group_by(palette) %>% mutate(i = 1:n()) %>% nest() %>% mutate( p = map2( palette, data, ~ggplot(data = .y, aes(x = i, y = 1, fill = reorder(colors, i))) + geom_tile() + geom_label(aes(label = colors), color = "white", fill = "black", size = 3) + scale_fill_manual(values = .y$colors) + theme_void() + theme(legend.position = "none") + labs(title = str_c(.x, " (", nrow(.y), ")")) ) ) reduce(palette_plots$p, `%+%`) + plot_layout(ncol = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.