Skip to content

commfish/theme_adfg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

theme_adfg

A ggplot2 theme for reproducible figures in R in a uniform Alaska Department of Fish and Game (ADF&G) style.

This theme creates a graph template for ADF&G biologists, biometricians, and scientists to create a uniform graph output style that conforms with ADF&G publication standards. This theme was created in collaboration with the ADF&G reproducibility crew and publication team, to create uniform and professional ADF&G figures. This work is heavily based on Andrew Padilla's theme_adfg draft code (I even stole the name) and theme_crisp by Justin Priest. The majority of this code was written by Padilla and Priest, and my contribution was just minor edits and finalizations.

This theme is still under review.

Installing theme_adfg

theme_adfg can be installed from GitHub with remotes

#install.packages("remotes")
remotes::install_github("commfish/theme_adfg")

FLAG**- set this up

Examples

The dataset "iris" the R package datasets was used for the examples.

Basic scatterplot:

ggplot(iris) + aes(x = Petal.Length, y= Petal.Width) + geom_point() +
    labs( x= "Petal length", y="Petal width") + 
    theme_adfg_2(box = "yes")

basic plot

Basic multipanel plot:

ggplot(iris) + aes(x = Petal.Length, y= Petal.Width) + geom_point() +
    labs( x= "Petal length", y="Petal width") + 
    theme_adfg_2(box = "yes")+ 
    facet_wrap(~Species, scales = "free")+
    guides(color = "none")

facet plot

Violin plot:

ggplot(iris) + aes(x = Species, y= Petal.Length, fill = Species) + geom_violin() +
    labs( x= "Species", y="Frequency") + 
    theme_adfg(legend.position.set = c(0.9, 0.2), box = "yes")+ #move legend to a good spot
    scale_fill_adfg(palette = "bristolbay", discrete = TRUE, useexact = TRUE)

violin plot

Colors

While frowned upon in official ADF&G publications, adding a color palette to a graph can greatly improve the impact, especially for posters and presentations. The theme itself is black and white, but colors can be added with adfg_colors, or any other R color palette of choice. adfg_colors has some ADF&G and Alaska-based color palettes.

Scatterplot:

ggplot(iris) + aes(x = Petal.Length, y= Petal.Width, color = Species) + geom_point() +
    labs( x= "Petal length", y="Petal width") + 
    theme_adfg(legend.position.set = c(0.9, 0.18), #move legend to a good spot
                 box ="yes" #border
    )+ 
    scale_color_adfg(palette = "bristolbay", discrete = TRUE, useexact = TRUE)

basic plot

Multipanel plot:

ggplot(iris) + aes(x = Petal.Length, y= Petal.Width, color = Species) + geom_point() +
    labs( x= "Petal length", y="Petal width") + 
    theme_adfg(box = "yes")+ 
    scale_color_adfg(palette = "bristolbay", discrete = TRUE, useexact = TRUE)+
    facet_wrap(~Species, scales = "free")+
    guides(color = "none")) #turn off legend, not needed here

facet plot

Violin plot:

ggplot(iris) + aes(x = Species, y= Petal.Length, fill = Species) + geom_violin() +
    labs( x= "Species", y="Frequency") + 
    theme_adfg(legend.position.set = c(0.9, 0.2), box = "yes")+ #move legend to a good spot
    scale_fill_adfg(palette = "bristolbay", discrete = TRUE, useexact = TRUE)

violin plot

Box

Use the argument box = "no" to turn off the box that surrounds the plot. This box was added to comply with ADF&G publication standards, but may not make sense for presentations or multi-panel plots.

About

A ggplot2 theme for reproducible figures in R.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages