Skip to content

Package to easily use common ADF&G colors schemes in ggplot2

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

justinpriest/adfgcolors

Repository files navigation

adfgcolors

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

This package allows users to easily add useful and aesthetic colors schemes in ggplot2. Influenced by the amazing packages nmfspalette and PNWColors. Much of the code for this package is from nmfspalette, written by Christine Stawitz.

adfgcolors is still in active development with new palettes being added. adfgcolors is not endorsed by ADF&G.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("justinpriest/adfgcolors")

Example Usage

adfgcolors allows you to quickly specify color palettes in ggplot by using the functions scale_fill_adfg() and scale_color_adfg(), shown below:

library(adfgcolors)
library(ggplot2)
ggplot(mpg, aes(class, fill = class)) +
  geom_bar(color = "black") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  scale_fill_adfg(palette = "glacier", discrete = TRUE) 

A common need is for plots to be in grayscale, shown here:

library(adfgcolors)
library(ggplot2)
ggplot(mpg, aes(class, fill = class)) +
  geom_bar(color = "black") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  scale_fill_adfg(palette = "grays_bw", discrete = TRUE) 

The color aesthetic is easy to modify:

library(adfgcolors)
library(ggplot2)
ggplot(mpg, aes(x=displ, y = cty, color = cyl)) +
  geom_point() + 
  scale_color_adfg(palette = "alpenglow", discrete = FALSE) 

Often, discrete variable plots look best if the exact order of colors are used (no interpolation), using argument useexact = TRUE:

library(adfgcolors)
library(ggplot2)
ggplot(mpg, aes(drv, fill = drv)) +
  geom_bar(color = "black") + 
  scale_fill_adfg(palette = "bristolbay", discrete = TRUE, useexact = TRUE) 


Palette Choices

Colors are generally divided into two categories, discrete and continuous. Palettes are able to be used as either type, though palettes described below as discrete display best when plotted for discrete data. Palettes are shown with hex codes for use in manual plotting, if desired. To show palettes, use function display_palette().

Continuous (Sequential) Palettes


Discrete (Categorical) Palettes

Consider using argument useexact = TRUE when plotting discrete variables as it will use the exact order of palettes shown below.

Other Palettes

More continuous palettes

More discrete palettes

Show Palette

Before plotting, you can show the palette using function display_palette(). The arguments for this are the palette name and the number of colors to display. The associated “hex codes” are shown to assist users who may want to manually select colors for use in their own palette.

display_palette("denali", 7)

About

Package to easily use common ADF&G colors schemes in ggplot2

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published