knitr::opts_chunk$set(
  collapse = TRUE,
  echo = FALSE,
  comment = "#>"
)
library(chromaticity)
library(ggplot2)

The purpose of this package is to automate and standardize aesthetic components of report writing. The following sections provide documentation regarding the various functions available in the package.

themer

This function stores a standardized ggplot2 theme with two inputs, font_size, which controls the size of the font and box, a logical which controls if there is a box drawn around the plot.

df <- data.frame(variable = factor(1:3, levels = 1:3), value = 1)

ggplot(df, aes(variable, value)) +
  geom_bar(stat = "identity") +
  themer(font_size = 11, box = T)

color_pickr

The purpose of this function is to ensure that color palettes are optimized for the number of colors selected by the user. For each of the four palettes provided by color_pickr, a different subset of the colors is returned based on the number of colors selected by the user. Examples of the color palettes are provided in the following sections.

When calling this function, the user needs to choose the number of colors in the palette and the name of the palette. Example of this function in use:

ggplot(df, aes(variable, value, fill = variable)) +
  geom_bar(stat = "identity") +
  themer() +
  scale_fill_manual(values = color_pickr(nrow(df), "Jalama"))

Jalama

for (xx in 1:10) {

    test <- data.frame(variable = factor(1:xx, levels = 1:xx), value = 1)

    print(
      ggplot(test, aes(variable, value, fill = variable)) +
        geom_bar(stat = "identity") +
        scale_fill_manual(values = color_pickr(xx, "Jalama")) +
        themer() +
        theme(legend.position = "none") +
        labs(x = NULL, y = NULL)

    )

}

Naples

for (xx in 1:5) {

    test <- data.frame(variable = factor(1:xx, levels = 1:xx), value = 1)

    print(
      ggplot(test, aes(variable, value, fill = variable)) +
        geom_bar(stat = "identity") +
        scale_fill_manual(values = color_pickr(xx, "Naples")) +
        themer() +
        theme(legend.position = "none") +
        labs(x = NULL, y = NULL)

    )

}

Refugio

for (xx in 1:6) {

    test <- data.frame(variable = factor(1:xx, levels = 1:xx), value = 1)

    print(
      ggplot(test, aes(variable, value, fill = variable)) +
        geom_bar(stat = "identity") +
        scale_fill_manual(values = color_pickr(xx, "Refugio")) +
        themer() +
        theme(legend.position = "none") +
        labs(x = NULL, y = NULL)

    )

}

Rincon

for (xx in 1:7) {

    test <- data.frame(variable = factor(1:xx, levels = 1:xx), value = 1)

    print(
      ggplot(test, aes(variable, value, fill = variable)) +
        geom_bar(stat = "identity") +
        scale_fill_manual(values = color_pickr(xx, "Rincon")) +
        themer() +
        theme(legend.position = "none") +
        labs(x = NULL, y = NULL)

    )

}

El Capitan

for (xx in 1:9) {

    test <- data.frame(variable = factor(1:xx, levels = 1:xx), value = 1)

    print(
      ggplot(test, aes(variable, value, fill = variable)) +
        geom_bar(stat = "identity") +
        scale_fill_manual(values = color_pickr(xx, "El Capitan")) +
        themer() +
        theme(legend.position = "none") +
        labs(x = NULL, y = NULL)

    )

}


bjornkallerud/chromaticity documentation built on June 15, 2020, 8:28 p.m.