Package 'nmfspalette'

Title: A Color Palette for NOAA Fisheries
Description: This is a package that implements a color palette in line with the NOAA Fisheries Branding Guide.
Authors: Christine Stawitz [aut], Bai Li [aut], Kathryn Doering [ctb], Sophie Breitbart [cre], Steve Saul [ctb], Sam Schiano [ctb]
Maintainer: Sophie Breitbart <[email protected]>
License: GPL-3 | file LICENSE
Version: 3.3.0.000
Built: 2026-05-21 10:16:02 UTC
Source: https://github.com/nmfs-ost/nmfspalette

Help Index


Return function that shows all nmfs color palettes

Description

Return function that shows all nmfs color palettes

Usage

all_nmfs_palettes()

Value

A null object showing all nmfs color palettes in the plot window.

Examples

all_nmfs_palettes()

Return interpolated nmfs color palette

Description

Return interpolated nmfs color palette

Usage

display_nmfs_palette(name, n)

Arguments

name

Character name of palette in nmfs_palettes.

n

Number of colors in palette.

Value

An object showing a specific nmfs color palette in the plot window.

Examples

display_nmfs_palette("oceans", 10)

Function to extract nmfs colors as hex codes

Description

Function to extract nmfs colors as hex codes

Usage

nmfs_cols(...)

Arguments

...

Character names of nmfs_colors

Examples

nmfs_cols("processblue")

Return function to interpolate a nmfs color palette

Description

Return function to interpolate a nmfs color palette

Usage

nmfs_palette(palette = "oceans", reverse = FALSE, ...)

Arguments

palette

Character name of palette in nmfs_palettes. Default value is "oceans".

reverse

Boolean indicating whether the palette should be reversed. Default value is FALSE.

...

Additional arguments to pass to grDevices::colorRampPalette().

Examples

nmfs_palette("oceans")(10)

# or equivalently
oceans_pal <- nmfs_palette("oceans")
oceans_pal(10)

Color scale constructor for nmfs colors

Description

Color scale constructor for nmfs colors

Usage

scale_color_nmfs(
  palette = "oceans",
  discrete = TRUE,
  reverse = FALSE,
  interpolate = TRUE,
  ...
)

Arguments

palette

Character name of palette in nmfs_palettes. Default value is "oceans".

discrete

Boolean indicating whether color aesthetic is discrete. Default is TRUE.

reverse

Boolean indicating whether the palette should be reversed. Default is FALSE.

interpolate

Boolean indicating whether the colors assigned to plot objects should interpolated from palettes, with the alternative that only the defined colors in the palette are used. Default is TRUE.

...

Additional arguments passed to: ggplot2::scale_color_gradientn() when discrete is TRUE; ggplot2::discrete_scale() when discrete is FALSE and interpolate is TRUE; and ggplot2::scale_color_manual() when discrete is FALSE and interpolate is FALSE.

Examples

library(ggplot2)
ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
  geom_point(size = 4) +
  scale_color_nmfs("coral")

ggplot(mtcars, aes(mpg, disp, color = as.factor(gear))) +
  geom_point(size = 4) +
  scale_color_nmfs("regional",
    interpolate = FALSE,
    discrete = TRUE
  )

Fill scale constructor for nmfs colors

Description

Fill scale constructor for nmfs colors

Usage

scale_fill_nmfs(
  palette = "oceans",
  discrete = TRUE,
  reverse = FALSE,
  interpolate = TRUE,
  ...
)

Arguments

palette

Character name of palette in nmfs_palettes. Default value is "oceans".

discrete

Boolean indicating whether color aesthetic is discrete. Default is TRUE.

reverse

Boolean indicating whether the palette should be reversed. Default is FALSE.

interpolate

Boolean indicating whether the colors assigned to plot objects should interpolated from palettes, with the alternative that only the defined colors in the palette are used. Default is TRUE.

...

Additional arguments passed to: ggplot2::scale_fill_gradientn() when discrete is TRUE; ggplot2::discrete_scale() when discrete is FALSE and interpolate is TRUE; and ggplot2::scale_fill_manual() when discrete is FALSE and interpolate is FALSE.

Examples

library(ggplot2)
ggplot(mpg, aes(x = hwy, y = cty, fill = cyl)) +
  geom_point(shape = 21) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  scale_fill_nmfs(palette = "crustacean", discrete = FALSE)

ggplot(mtcars, aes(mpg, disp, color = as.factor(gear))) +
  geom_point(size = 4) +
  scale_fill_nmfs("regional",
    interpolate = FALSE,
    discrete = TRUE
  )

Create theme for nmfs colors

Description

Create theme for nmfs colors

Usage

theme_nmfs(
  palette = "oceans",
  discrete = TRUE,
  reverse = FALSE,
  interpolate = TRUE,
  base_size = 14,
  lab_size = 12,
  ink = "black",
  paper = "white",
  accent = "#003087",
  ...
)

Arguments

palette

Character name of palette in nmfs_palettes. Default value is "oceans".

discrete

Boolean indicating whether color aesthetic is discrete. Default is TRUE.

reverse

Boolean indicating whether the palette should be reversed. Default is FALSE.

interpolate

Boolean indicating whether the colors assigned to plot objects should interpolated from palettes, with the alternative that only the defined colors in the palette are used. Default is TRUE.

base_size

The base font size, as defined in the ggplot2::theme_gray() function

lab_size

The axis text size

ink

The plot foreground color, as defined in the ggplot2::theme_gray() function

paper

The plot background color, as defined in the ggplot2::theme_gray() function

accent

The plot's accented elements' color, as defined in the ggplot2::theme_gray() function

...

Additional arguments passed to: ggplot2::scale_fill_gradientn() when discrete is TRUE; ggplot2::discrete_scale() when discrete is FALSE and interpolate is TRUE; and ggplot2::scale_fill_manual() when discrete is FALSE and interpolate is FALSE.

Value

A theme that applies nmfs color palettes and theme-related elements (such as label sizes, borders, axis lines, and more) to a plot. For more information about the ggplot2 advances that enabled this function, check out the ggplot2 version 4.0.0 release notes.

Examples

library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = disp, color = as.factor(cyl))) +
  geom_point(size = 3) +
  theme_nmfs(discrete = TRUE, interpolate = TRUE, palette = "crustacean")
ggplot(mtcars, aes(x = mpg, y = disp, color = as.factor(cyl))) +
  geom_point(size = 3) +
  theme_nmfs(discrete = TRUE, interpolate = FALSE, palette = "crustacean")
ggplot(mtcars, aes(x = mpg, y = disp, fill = hp)) +
  geom_point(size = 3, shape = 24) +
  theme_nmfs(discrete = FALSE, interpolate = TRUE, palette = "seagrass")