Skip to content

Commit

Permalink
Fix nmfscols --> nmfs_cols in nmfs_cols.R; update test; update README…
Browse files Browse the repository at this point in the history
… with new palettes
  • Loading branch information
sbreitbart-NOAA committed Mar 6, 2025
1 parent e3c0152 commit 1bb75dd
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 30 deletions.
31 changes: 17 additions & 14 deletions R/nmfs_cols.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ nmfs_colors <- c(


# 2023 fisheries complementary colors
# All of these palettes, except for the teal palette, are identical to the
# oceans, waves, urchin, etc. palettes above.

# "dark_green_teal" # already defined above
"teal_green" = "#008DA8",
"teal_green" = "#008DA8", # this color differs from the waves' second color
# "bright_teal" # already defined above
# "pale_teal" # already defined above

Expand Down Expand Up @@ -184,22 +186,22 @@ nmfs_palettes <- list(
`coral` = nmfs_cols("bright_coral", "vivid_coral", "pacificislands", "dark_coral"),
`regional` = nmfs_cols("national", "westcoast", "southeast", "midatlantic", "alaska", "pacificislands"),

`core` = nmfscols("noaa_sky", "noaa_sea", "whale_gray", "midnight_sky", "twilight_sky", "light_sea_blue", "pale_sea_blue", "medium_sea_blue", "deep_sea_blue", "dove_gray", "gull_white"),
`complement_teal` = nmfs_cols("dark_green_teal", "teal_green", "bright_teal", "pale_teal"),
`complement_seagrass` = nmfs_cols("dark_seagrass", "seagrass", "vivid_seagrass", "bright_seagrass"),
`complement_urchin` = nmfs_cols("dark_urchin", "urchin", "vivid_urchin", "bright_urchin"),
`complement_crustacean` = nmfs_cols("dark_crustacean", "crustacean", "vivid_crustacean", "bright_crustacean"),
`complement_coral` = nmfs_cols("dark_coral", "coral", "vivid_coral", "bright_coral"),

`complement_teal` = nmfscols("dark_green_teal", "teal_green", "bright_teal", "pale_teal"),
`complement_seagrass` = nmfscols("dark_seagrass", "seagrass", "vivid_seagrass", "bright_seagrass"),
`complement_urchin` = nmfscols("dark_urchin", "urchin", "vivid_urchin", "bright_urchin"),
`complement_crustacean` = nmfscols("dark_crustacean", "crustacean", "vivid_crustacean", "bright_crustacean"),
`complement_coral` = nmfscols("dark_coral", "coral", "vivid_coral", "bright_coral"),
`background_sky` = nmfs_cols("midnight_sky", "sky_tint_1", "sky_tint_2", "sky_tint_3"),
`background_green` = nmfs_cols("turtle_green", "green_tint_1", "green_tint_2", "green_tint_3"),
`background_gray` = nmfs_cols("whale_gray", "dove_gray_tint_1", "dove_gray_tint_2", "gray_tint_3"),

`background_sky` = nmfscols("midnight_sky", "sky_tint_1", "sky_tint_2", "sky_tint_3"),
`background_green` = nmfscols("turtle_green", "green_tint_1", "green_tint_2", "green_tint_3"),
`background_gray` = nmfscols("whale_gray", "dove_gray_tint_1", "dove_gray_tint_2", "gray_tint_3"),
`core` = nmfs_cols("noaa_sky", "noaa_sea", "whale_gray", "midnight_sky", "twilight_sky", "light_sea_blue", "pale_sea_blue", "medium_sea_blue", "deep_sea_blue", "dove_gray", "gull_white"),

`alert_red` = nmfscols("dark_red", "red", "vivid_red", "bright_red"),
`alert_orange` = nmfscols("dark_orange", "orange", "vivid_orange", "bright_orange"),
`alert_yellow` = nmfscols("dark_yellow", "yellow", "vivid_yellow", "bright_yellow"),
`alert_green` = nmfscols("dark_green", "green", "vivid_green", "bright_green")
`alert_red` = nmfs_cols("dark_red", "red", "vivid_red", "bright_red"),
`alert_orange` = nmfs_cols("dark_orange", "orange", "vivid_orange", "bright_orange"),
`alert_yellow` = nmfs_cols("dark_yellow", "yellow", "vivid_yellow", "bright_yellow"),
`alert_green` = nmfs_cols("dark_green", "green", "vivid_green", "bright_green")
)

#' Return function to interpolate a nmfs color palette
Expand Down Expand Up @@ -289,3 +291,4 @@ scale_fill_nmfs <- function(palette = "oceans", discrete = TRUE, reverse = FALSE
scale_fill_gradientn(colours = pal(256), ...)
}
}

83 changes: 69 additions & 14 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ 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 christine.stawitz@noaa.gov (NOAA Affiliates only). We ask that all contributors adhere to The NOAA Fisheries Integrated Toolbox [code of conduct](https://github.com/nmfs-fish-tools/Resources/blob/main/CONTRIBUTING.md).
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 sophie.breitbart@noaa.gov (NOAA Affiliates only). We ask that all contributors adhere to The NOAA Fisheries Integrated Toolbox [code of conduct](https://github.com/nmfs-fish-tools/Resources/blob/main/CONTRIBUTING.md).


## Usage
Expand All @@ -48,44 +48,99 @@ nmfspalette::nmfs_palette("oceans")(10)
## Palettes
To see the palettes, use the `display_nmfs_palette()` function.

### oceans
### Main NOAA Fisheries palettes
These palettes contain 4 or 6 colors.

#### oceans
```{r, fig.height = 2, displ_oceans}
nmfspalette::display_nmfs_palette("oceans", 6)
```

### waves
#### waves
```{r, fig.height = 2, displ_waves}
nmfspalette::display_nmfs_palette("waves", 6)
nmfspalette::display_nmfs_palette("waves", 4)
```

### seagrass
#### seagrass
```{r, fig.height = 2, displ_seagrass}
nmfspalette::display_nmfs_palette("seagrass", 6)
nmfspalette::display_nmfs_palette("seagrass", 4)
```

### urchin
#### urchin
```{r, fig.height = 2, displ_urchin}
nmfspalette::display_nmfs_palette("urchin", 6)
nmfspalette::display_nmfs_palette("urchin", 4)
```

### crustacean
#### crustacean
```{r, fig.height = 2, displ_crustacean}
nmfspalette::display_nmfs_palette("crustacean", 6)
nmfspalette::display_nmfs_palette("crustacean", 4)
```

### coral
#### coral
```{r, fig.height = 2, displ_coral}
nmfspalette::display_nmfs_palette("coral", 6)
nmfspalette::display_nmfs_palette("coral", 4)
```

### regional (discrete)
#### regional (discrete)
```{r, fig.height = 2, displ_regional_web}
nmfspalette::display_nmfs_palette("regional", 6)
```

### NOAA Fisheries complementary colors
These 5 palettes contain 4 complementary colors each. With the exception of the waves/complementary teal palettes (which vary in 1/4 colors), the remaining palettes are identical to the main NOAA Fisheries palettes. Check out the [nmfs_cols.R file](https://github.com/nmfs-fish-tools/nmfspalette/blob/main/R/nmfs_cols.R) for more information.

### NOAA Fisheries background & tint colors
These palettes contain 4 colors.

#### background sky
```{r, fig.height = 2, displ_background_sky}
nmfspalette::display_nmfs_palette("background_sky", 4)
```

#### background green
```{r, fig.height = 2, displ_background_green}
nmfspalette::display_nmfs_palette("background_green", 4)
```

#### background gray
```{r, fig.height = 2, displ_background_gray}
nmfspalette::display_nmfs_palette("background_gray", 4)
```


### NOAA core colors (Fisheries version)
This palette contains 11 colors.

```{r, fig.height = 2, displ_core}
nmfspalette::display_nmfs_palette("core", 11)
```

### NOAA alert colors
These palettes contain 4 colors.

#### alert red
```{r, fig.height = 2, displ_alert_red}
nmfspalette::display_nmfs_palette("alert_red", 4)
```

#### alert orange
```{r, fig.height = 2, displ_alert_orange}
nmfspalette::display_nmfs_palette("alert_orange", 4)
```

#### alert yellow
```{r, fig.height = 2, displ_alert_yellow}
nmfspalette::display_nmfs_palette("alert_yellow", 4)
```

#### alert green
```{r, fig.height = 2, displ_alert_green}
nmfspalette::display_nmfs_palette("alert_green", 4)
```

## 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](https://drive.google.com/drive/folders/1pcMRQHGdzX4NfsiDNTCYIBpRyP1-F57J)(NOAA internal only) for color names. Here, all spaces are removed in the color names.
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](https://drive.google.com/drive/folders/1pcMRQHGdzX4NfsiDNTCYIBpRyP1-F57J) (NOAA internal only) for color names. Here, all spaces are removed in the color names.

```{r, nmfs_cols}
nmfspalette::nmfs_cols("processblue")
Expand Down
Binary file modified man/figures/default_plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_coral-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_crustacean-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_oceans-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_regional_web-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_seagrass-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_urchin-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/displ_waves-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/scale_fill_example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions tests/testthat/test-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ test_that("palette works", {
# Check that nmfs_palette(n) returns a vector
i <- nmfs_palette("crustacean")(10)
expect_equal(i, c(
"#FFD4A6", "#FFBD78", "#FFA74A", "#FF911C",
"#F77C04", "#E36810", "#C7570E", "#A54902", "#873C00", "#6A2F00"
"#FFAB38", "#FF9E25", "#FF9112", "#FF8400",
"#F37807", "#E66C0E", "#DB6015", "#BE530E",
"#A14707", "#853B00"
))

# Check that fake palette names create an error
Expand Down

0 comments on commit 1bb75dd

Please sign in to comment.