MyNixOS website logo
Description

Color Palettes Inspired by Nature in the US Pacific Northwest.

PNW-Inspired Palettes for 'R' data visualizations. Palettes are variable in length and checked for colorblind accessibility from hue, saturation, and lightness value scaling using the 'Chroma.js Color Palette Helper' <https://gka.github.io/palettes/>.

PNW Color Palette Package for R

I am soon moving away from the most beautiful place I will ever live, so I did what any nostalgic nature kid / data science nerd would do and immortalized it in an R color palette package. Now I (and you!) can have the colors of Washington State and the Pacific Northwest live on in our presentation figures forever.

All photos were taken by me in places that I love. The Pantone Studio iPhone app helped me extract colors, and Chroma.js Color Palette Helper helped me adjust values to ensure that all palettes are color-blind safe to be used for attractive and inclusive data viz. Structure of the code was inspired by the wesanderson and LaCroixColoR packages from GitHub. See more examples on twitter.

Install Package

install.packages("devtools") 
devtools::install_github("jakelawlor/PNWColors") 

Usage

library(PNWColors)

names(pnw_palettes)
 [1] "Starfish" "Shuksan"  "Bay"      "Winter"   "Lake"     "Sunset"   "Shuksan2" 
 [8] "Cascades" "Sailboat" "Moth" "Spring"   "Mushroom" "Sunset2"  "Anemone"    

Palettes

  • Low Tide -- San Juan Islands, Washington
  • 
    
  • Mount Shuksan from Mount Baker Ski Resort -- North Cascades, Washington
  • View from a sunset kayak -- Bellingham Bay, Washington
  • Washington Park snowday -- Anacortes, Washington
  • Whistle Lake, the best place in the world -- Anacortes, Washington
  • Washington Park sunset -- Anacortes, Washington
  • Mount Shuksan, golden hour -- North Cascades, Washington
  • Watson Lake Trail End -- North Cascades, Washington
  • Moth -- Vendovi Island, Washington
  • Funky Dory Sailboat -- Anacortes, Washington
  • Oyster Dome Sunset -- Chuckanut, Washington
  • Cherry Blossoms -- Anacortes, Washington
  • Anchor Cove -- Anacortes, Washington
  • Mushroom Hunting -- Orcas Island, Washington

Building Palettes

Use the pnw_palette() function to build and view palettes. Inputs are 'name', 'n', and 'type' (continuous or discrete). 'Name' is required. If 'n' is blank, function will assume n is equal to the number of colors in the palette (5-8), but if n > palette length, it will automatically interpolate colors between. If 'type' is missing, the function will assume "discrete" if n < palette length, and "continuous" if n > palette length.

pnw_palette(name="Starfish",n=7,type="discrete")
pnw_palette("Winter",100)
pnw_palette("Bay",8,type="continuous")
pnw_palette("Moth",12)

Example Plots

Palettes can be easily integrated into Base R imaging or ggplot2.

pal <- pnw_palette("Shuksan",100)
image(volcano, col = pal)
pal=pnw_palette("Lake",5, type = "discrete")
ggplot(diamonds, aes(carat, fill = cut)) +
  geom_density(position = "stack") +
  scale_fill_manual(values=pal)  +
  theme_classic()
pal=pnw_palette("Shuksan2",100)
ggplot(data.frame(x = rnorm(1e4), y = rnorm(1e4)), aes(x = x, y = y)) +
  geom_hex() +
  coord_fixed() +
  scale_fill_gradientn(colours = pal) +
  theme_classic()
  
  # Or, to switch the order, use rev(), see below
  scale_fill_gradientn(colours = rev(pal))
ggplot(data = iris,aes(x=Petal.Length,y=Petal.Width,color=Species))+
  geom_point(size=2)+
  scale_color_manual(values=pnw_palette("Spring",3))+
  theme_classic()
pal <- pnw_palette("Anemone",3)
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) + 
 geom_violin(trim=FALSE)+
 geom_boxplot(width=0.1, fill="white")+
 labs(title="Plot of length  by dose",x="Dose (mg)", y = "Length")+
 scale_fill_manual(values=pal)+
 theme_classic()
library(tidyverse)
library(urbnmapr)
pal <- pnw_palette("Winter",100)
countydata %>%
 left_join(counties, by = "county_fips") %>%
 filter(state_name =="Washington") %>%
 ggplot(mapping=aes(long,lat,group = group, fill = horate)) +
 geom_polygon(color="black",size=.25) +
 scale_fill_gradientn(colours = pal) +
 coord_map(projection="albers",lat0=39,lat1=45) +
 theme(legend.title = element_text(),
       legend.key.width = unit(.5,"in")) +
 labs(fill="Homeownership rate") +
 theme_void()
 

Contact

Used the palettes in your paper and care to share? (please do!)
Love the palettes and want to share?
Reach me at [email protected] or @Jake_Lawlor1

This work was supported by NSF grant #1538626
Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows