FNGr: Fish and Game ggplot figure style

Description Usage Examples

Description

This is a style generator so that figures have the same general appearance within the Alaska Department of Fish and Game. theme_sleek() is directly stolen from Sean Anderson! http://seananderson.ca/

Usage

1
2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(devtools)
devtools::install_github("ben-williams/FNGr")
library(FNGr)
library(tidyverse)
library(scales)
theme_set(theme_sleek())

data.frame(year = 1973:2017, age = 1:5) 
  mutate(y = rnorm(n(), 10,5)) -> df

  The basic ggplot figure spaces years about every 5-10, depending on the timeseries length.

ggplot(df, aes(year, age, size = y)) + geom_point()  + scale_size_area()

  This makes for a rather poor axis, for our typical presentation needs.
  We can clean this up somewhat by using breaks or the pretty_breaks function from the scales package

ggplot(df, aes(year, age, size = y)) + geom_point() + scale_size_area() +
    scale_x_continuous(breaks = seq(1973, 2016, 3))

ggplot(df, aes(year, age, size = y)) + geom_point() +
  scale_x_continuous(breaks = pretty_breaks(n = 15))

  However this does not show a tick for each year, something that has been regularly requested.
  tickr will add a tick mark to each year and provide a label for the interval designated.

Labels every 10 years.

xaxis = tickr(df, year, 10)
yaxis = tickr(df, age, 2)

ggplot(df, aes(year, age, size = y)) + geom_point() +
  scale_x_continuous(breaks = xaxis$breaks, labels = xaxis$labels) +
  scale_y_continuous(breaks = yaxis$breaks, labels = yaxis$labels)

ben-williams/FNGr documentation built on May 30, 2019, 6:25 a.m.