R Themes - adunna/calipr-utils GitHub Wiki

calipr-utils contains R themes to aid in maintaining a sleek, unified plotting format across projects.

Requirements

The following packages are required:

  • ggplot2
  • ggthemes
  • RColorBrewer

They can be installed via:

install.packages(c('ggplot2', 'ggthemes', 'RColorBrewer'))

Or, to specify a repository:

install.packages(c('ggplot2', 'ggthemes', 'RColorBrewer'), repos = c(CRAN = "http://cran.rstudio.com"))

Themes / Examples

calipr: The (un)official Calipr Lab ggplot2 theme.

Usage

Include the selected theme file at the top of your R script, underneath the necessary includes specified above, with the source command, like so:

library(ggplot2)
library(ggthemes)
library(RColorBrewer)
source("calipr.r")

Then, apply the theme, which will be a function named by theme_name(), for example theme_calipr(), in the following format:

theme_calipr(plot)

You can also apply theme colors through this function by passing in extra arguments:

theme_calipr(plot, fc="color", dtype="qual")

in which fc is the type of color, either "fill" or "color", and dtype is the data type, either "qual", "seq", or "div", standing for qualitative (categorical), sequential (gradient), and diverging (emphasizes values at extremes), respectively.

Advanced Usage

If you would like to use your own theme, or make tweaks and just apply the colors, you can use the individual functions. Here is are examples using the Calipr theme:

calipr_color_seq(plot)
calipr_color_div(plot)
calipr_color_qual(plot)
calipr_fill_seq(plot)
calipr_fill_div(plot)
calipr_fill_qual(plot)