knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 8, 
  fig.height = 4,
  warning = FALSE,
  message = FALSE
)

Introduction

The pwdthemes R package includes several color palettes that are based on the style guide provided by the Public Affairs division of the Philadelphia Water Department (PWD). These palettes can be accessed using the pwd_pals() functional or more easily through the scale_color_pwd and scale_fill_pwd ggplot2 scale functions. This guide displays what the full palettes look like.

library(ggplot2)
library(patchwork)
library(ggridges)
library(pwdthemes)

First, I will create the base figures and define a helper function to render the different figures with each palette

large_diamonds <- diamonds[diamonds$carat > 2.2, ]

pc <- ggplot(large_diamonds, aes(price, carat, color = cut)) + 
  geom_point() + 
  theme_pwd()

pf <- ggplot(large_diamonds, aes(price, cut, fill = cut)) + 
  geom_density_ridges() + 
  theme_pwd()

display_pals <- function(p1 = pc, p2 = pf, pal){
  p1_out <- p1 + scale_color_pwd(pal)
  p2_out <- p2 + scale_fill_pwd(pal)

  out <- p1_out + p2_out

  return(out)
}

Main

pc_main <- pc + scale_color_pwd("main")
pf_main <- pf + scale_fill_pwd("main")

pc_main + pf_main

view_pwd_palette("main")

Primary

pc_main_dark <- pc + scale_color_pwd("primary")
pf_main_dark <- pf + scale_fill_pwd("primary")

pc_main_dark + pf_main_dark

view_pwd_palette("primary")

Highlights

pc_main_light <- pc + scale_color_pwd("highlight")
pf_main_light <- pf + scale_fill_pwd("highlight")

pc_main_light + pf_main_light

view_pwd_palette("highlight")


tbradley1013/pwdthemes documentation built on April 2, 2022, 1:34 a.m.