library(dplyr, warn.conflicts = FALSE)
library(ggplot2)
library(templates)
Brad Cannell’s templates and themes
You can install templates from GitHub with:
devtools::install_github("brad-cannell/templates")
The templates package contains several Rmd document templates. They are
located in inst/rmarkdown/templates
.
The templates package contains several color palettes. The easiest way
to access them is from the my_colors
data frame.
data(my_colors)
knitr::kable(my_colors)
group | subgroup | hex | description |
---|---|---|---|
bradcannell | Primary | #000000 | Black |
bradcannell | Primary | #FFFFFF | White |
uthealth | Primary | #ae6042 | University Orange |
uthealth | Primary | #4e738a | University Blue |
uthealth | Primary | #747578 | University Gray |
uthealth | Secondary | #002856 | Gulf Blue |
uthealth | Secondary | #f2b826 | Mustard Gold |
uthealth | Secondary | #587e6a | Dark Sage |
uthealth | Secondary | #7D708f | Dusty Lavender |
uthealth | Neutral | #b0bfbc | Light Sage |
uthealth | Neutral | #b6a999 | Sand |
florida | Primary | #f24f00 | Core Orange |
florida | Primary | #003896 | Core Blue |
florida | Primary | #FA4616 | Screen Orange |
florida | Primary | #0021A5 | Screen Blue |
florida | Secondary | #D32737 | Bottlebrush |
florida | Secondary | #F2A900 | Alachua |
florida | Secondary | #22884C | Gator |
florida | Secondary | #002657 | Dark Blue |
florida | Secondary | #6A2A60 | Perennial |
Here’s a function to help create the color plots below.
color_plots <- function(.group) {
df <- my_colors %>%
filter(group == .group) %>%
group_by(subgroup) %>%
mutate(x = row_number()) %>%
ungroup() %>%
mutate(hex = factor(hex, hex, hex))
ggplot(df, aes(x = x, y = 1, fill = hex)) +
geom_raster() +
geom_text(aes(label = description), color = "white") +
facet_wrap(vars(subgroup), ncol = 1) +
scale_fill_manual("Hexidecimal code", values = as.character(df$hex)) +
theme(
# Remove background
panel.background = element_rect(fill = "transparent"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_rect(fill = "transparent"),
# Remove x axis
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
# Remove y axis
axis.title.y = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
# Facet labels
strip.background = element_rect(color = "black", fill = "transparent")
)
}
# For testing
color_plots("uthealth")
Currently, the bradcannell color palette only contains black and white. There is no need to “show” it.
color_plots("uthealth")
color_plots("florida")
The templates package contains several logos and images. They are
located in man/figures
. Here is a sample.