Skip to content

nmfs-ost/nmfspalette

Repository files navigation

nmfspalette logo with an image of a fish in multiple palette colors

call-r-cmd-check

coverage

An R color palette for {ggplot2} using NOAA Fisheries branding colors.

{nmfspalette} implements these steps to create a {ggplot2} compatible palette according to NOAA Fisheries branding (NOAA internal only).

Installation

You can install the development version of nmfspalette from GitHub with:

# install.packages("pak")
pak::pak("nmfs-ost/nmfspalette")

To load the package, use:

library(nmfspalette)

Contributing

We welcome contributions to {nmfspalette}. You are welcome to make any changes you would like on a fork and submit a pull request. For more substantial changes or to create a branch, please contact [email protected] (NOAA Affiliates only). We ask that all contributors adhere to The NOAA Fisheries Integrated Toolbox code of conduct.

Usage

To learn how to use nmfspalette, please check out the interactive learnr tutorial.

Extract an interpolated color palette from the default “oceans” palette.

You can change the number of colors (10 shown below).

nmfs_palette("oceans")(10)
#>  [1] "#C6E6F0" "#8CCBE3" "#53B0D7" "#1F95CF" "#0072BB" "#004295" "#002B7B"
#>  [8] "#002467" "#001D55" "#001743"

Theme for ggplot objects

New feature: With the new theme_nmfs() function, you can add a NMFS-colored theme to your ggplot objects! This new theme that applies NMFS color palettes and theme-related elements (such as label sizes, borders, axis lines, and more) to a plot.

library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = disp, color = as.factor(cyl))) +
  geom_point(size = 3) +
  nmfspalette::theme_nmfs(discrete = TRUE, interpolate = TRUE, palette = "crustacean")
#> Warning: This function may not work if your `ggplot2` version is below 4.0.0. Update your package version to utilize this new function!
#> This warning is displayed once per session.

Image

Palettes

Use the all_nmfs_palettes() function to see all available palettes.

all_nmfs_palettes()

Image

Use the display_nmfs_palette() function to see a specific palette.

Main NOAA Fisheries palettes

These palettes contain 4 or 6 colors.

oceans

display_nmfs_palette("oceans", 6)

Image

waves

display_nmfs_palette("waves", 4)

Image

seagrass

display_nmfs_palette("seagrass", 4)

Image

urchin

display_nmfs_palette("urchin", 4)

Image

crustacean

display_nmfs_palette("crustacean", 4)

Image

coral

display_nmfs_palette("coral", 4)

Image

regional (discrete)

display_nmfs_palette("regional", 6)

Image

Alternative regional palettes

For some with color vision deficiency (C.V.D.), it may be difficult to discern the colors in the regional palette. We have provided two alternative regional palettes, below. Note: The alternative palette 1 contains colors that are entirely within the NMFS brand color set; alternative palette 2 does not. However, the colors in alternative palette 1 may be less distinguishable for all types of color perception as opposed to alternative palette 2.

nmfspalette::display_nmfs_palette("regional_alt1", 6)

Image

nmfspalette::display_nmfs_palette("regional_alt2", 6)

Image

NOAA Fisheries complementary colors

These 5 palettes contain 4 complementary colors each and are identical to the main NOAA Fisheries palettes, but some colors have different names. Check out the nmfs_cols.R file for more information.

NOAA Fisheries background & tint colors

These palettes contain 4 colors.

background sky

display_nmfs_palette("background_sky", 4)

Image

background green

display_nmfs_palette("background_green", 4)

Image

background gray

display_nmfs_palette("background_gray", 4)

Image

NOAA core colors (Fisheries version)

This palette contains 11 colors.

display_nmfs_palette("core", 11)

Image

NOAA alert colors

These palettes contain 4 colors.

alert red

display_nmfs_palette("alert_red", 4)

Image

alert orange

display_nmfs_palette("alert_orange", 4)

Image

alert yellow

display_nmfs_palette("alert_yellow", 4)

Image

alert green

display_nmfs_palette("alert_green", 4)

Image

Examples

In addition to nmfs_palette and display_nmfs_palette to get palettes, you can extract colors by name. Please see the NOAA Fisheries Branding guide (NOAA internal only) for color names. Here, for most color names, underscores are used in place of spaces. Colors defined before 2023 have no spaces in the color names.

nmfs_cols("vivid_crustacean")
#> vivid_crustacean 
#>        "#FF8400"
nmfs_cols("processblue")
#> processblue 
#>   "#0085CA"

To use the palettes with {ggplot2}, the scale_color_nmfs() and scale_fill_nmfs() functions are provided. If no argument is given to scale_color_nmfs(), a default (“oceans”) is used:

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

Image

scale_fill_nmfs() does not have a default and therefore requires a named argument, this is an example using the “crustacean” palette:

ggplot(faithfuld, aes(waiting, eruptions)) +
  geom_raster(aes(fill = density)) +
  scale_fill_nmfs(palette = "crustacean", discrete = FALSE, reverse = TRUE)

Image


Disclaimer

“The United States Department of Commerce (DOC) GitHub project code is provided on an ‘as is’ basis and the user assumes responsibility for its use. DOC has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any claims against the Department of Commerce stemming from the use of its GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.”


NOAA Fisheries

U.S. Department of Commerce | National Oceanographic and Atmospheric Administration | NOAA Fisheries

About

🎨 R color palettes for NOAA Fisheries official colors

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 9