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

pLtemplate

The goal of pLtemplate is to provide a consistent theme for ggplot graphics in the Paegel lab.

Installation

You can install pLtemplate from GitHub with:

# install.packages("devtools")
devtools::install_github("vcavett/pLtemplate")

Example

This is a sample scatter plot using the Paegel lab theme.

library(tidyverse)
library(pLtemplate)
library(scales)

data <- tibble(x = 0:100,
                             y = sample(1:1000, 101, replace=TRUE),
                             z = sample(LETTERS[1:3], 101, replace = TRUE),
                             a = sin(x))

data %>% ggplot() +
    aes(x, y,
            col = z) +
    geom_point(size= 3) +
    xlab("axis_label") +
    labs(title = "This is the main title",
             subtitle = "with subtitle",
             caption = "This is a random scatter plot prepared for theme demonstration.") +
  theme_pL() +
    scale_color_pL()

data %>% 
    ggplot() +
    aes(x, a) +
    geom_line() +
    scale_y_continuous(limits = c(-1,1), breaks = c(-1, 0, 1)) +
    labs(title = "line plot example",
             subtitle = "with subtitle",
             caption = "and a small descriptive caption describing the data") +
    theme_pL()

data %>% 
    group_by(z) %>% 
    summarize(letters = n(),
                        err = letters - dim(data)[1] / n_distinct(data$z))  %>% 
    ggplot() +
    aes(x = z, 
            y = letters) +
    geom_col() + 
    geom_errorbar(aes(ymin = letters - err,
                                        ymax = letters + err),
                                width = 0.2) +
    labs(title = "bar plot",
             subtitle = "by request") +
    theme_pL() +
    scale_fill_pL()

Some graphical elements will still need to be set manually (eg, axis breaks).



vcavett/pLtemplate documentation built on Feb. 6, 2022, 2:53 a.m.