knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

kubrand

Codecov test coverage R-CMD-check

The goal of kubrand is to simplify theming a ggplot2 graph using KU branded colors.

Installation

The development version of the package is available from GitHub with:

# install.packages("remotes")
remotes::install_github("bvancilku/kubrand")

Example

Make a plot using the KU-branded ggplot2 theme:

library(dplyr)
library(ggplot2)
library(magrittr)
library(purrr)

library(kubrand)
base::set.seed(2021L + 07L + 05L)
dataset <- tibble::tibble(
  val_x_true = base::seq(1, 100, by = 1)
) %>% 
  dplyr::mutate(
    val_x_measured = val_x_true + stats::rnorm(dplyr::n(), mean = 0, sd = 0.6),
    ind_treatment = purrr::rbernoulli(dplyr::n()),
    val_y_true = val_x_true * (1.1 + (1 - 0.4 * ind_treatment) * base::sin(val_x_true / 10)),
    val_y_measured = val_y_true + stats::rnorm(dplyr::n(), mean = 0, sd = 5),
    cat_treatment = base::factor(dplyr::if_else(ind_treatment, "treatment", "control"), levels = c("control", "treatment"))
  )

categorical_palette <- kubrand::ku_pal("cat2_int", reverse = TRUE)(2L)
dataset %>% 
  ggplot2::ggplot() +
  ggplot2::aes(x = val_x_measured, y = val_y_measured, color = cat_treatment, shape = cat_treatment) +
  ggplot2::geom_point(show.legend = FALSE) +
  ggplot2::xlab("x") +
  ggplot2::ylab("y") +
  kubrand::scale_color_ku("cat2_int", reverse = TRUE) +
  ggplot2::ggtitle(
    label = glue::glue("The **{kubrand::color_text(categorical_palette[[2]], 'treatment')}** attenuates oscillation relative to the **{kubrand::color_text(categorical_palette[[1]], 'control')}**"),
    subtitle = "Sometimes one needs a subtitle. This is not one of those times."
  ) +
  theme_ku()

Code of conduct

Please note that the kubrand project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Related work

This package relies on the hard work of other package maintainers as well as many good tutorials and articles. Please allow us to commend them here.

Articles

Packages

Tools



bvancilku/kubrand documentation built on July 26, 2022, 6:23 a.m.