-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.Rmd
126 lines (92 loc) · 5.13 KB
/
README.Rmd
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
output:
md_document:
variant: gfm
---
<!-- README.md is generated from README.Rmd. Please edit README.Rmd -->
```{r, echo = FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
fig.height = 1
)
require(ggplot2)
```
# nmfspalette <a href={https:://nmfs-fish-tools.github.io/nmfspalette}><img src="man/figures/logo.png" align="right" width=139 height=139 alt="logo with an image of a fish in multiple palette colors" />
An R color palette for `{ggplot2}` using NOAA Fisheries branding colors
[![call-r-cmd-check](https://github.com/nmfs-fish-tools/nmfspalette/actions/workflows/call-r-cmd-check.yml/badge.svg)](https://github.com/nmfs-fish-tools/nmfspalette/actions/workflows/call-r-cmd-check.yml)
**************
`{nmfspalette}` implements these [steps](https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2) to create a `{ggplot2}` compatible palette according to [NOAA Fisheries branding](https://drive.google.com/drive/folders/1pcMRQHGdzX4NfsiDNTCYIBpRyP1-F57J)(NOAA internal only).
## Installation
To install from GitHub use the following:
```{r, message=FALSE}
remotes::install_github("nmfs-fish-tools/nmfspalette")
```
To load the package, use:
```{r, message=FALSE}
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).
## Usage
To learn how to use `nmfspalette`, please check out the [interactive `learnr` tutorial](https://connect.fisheries.noaa.gov/colors/).
Extract an interpolated color palette from the default "oceans" palette.
You can change the number of colors (10 shown below).
```{r, default_pal}
nmfspalette::nmfs_palette("oceans")(10)
```
## Palettes
To see the palettes, use the `display_nmfs_palette()` function.
### oceans
```{r, fig.height = 2, displ_oceans}
nmfspalette::display_nmfs_palette("oceans", 6)
```
### waves
```{r, fig.height = 2, displ_waves}
nmfspalette::display_nmfs_palette("waves", 6)
```
### seagrass
```{r, fig.height = 2, displ_seagrass}
nmfspalette::display_nmfs_palette("seagrass", 6)
```
### urchin
```{r, fig.height = 2, displ_urchin}
nmfspalette::display_nmfs_palette("urchin", 6)
```
### crustacean
```{r, fig.height = 2, displ_crustacean}
nmfspalette::display_nmfs_palette("crustacean", 6)
```
### coral
```{r, fig.height = 2, displ_coral}
nmfspalette::display_nmfs_palette("coral", 6)
```
### regional (discrete)
```{r, fig.height = 2, displ_regional_web}
nmfspalette::display_nmfs_palette("regional", 6)
```
## 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.
```{r, nmfs_cols}
nmfspalette::nmfs_cols("processblue")
```
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:
```{r, default_plot, fig.height=3}
p <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
geom_point(size = 4) +
scale_color_nmfs()
p
```
`scale_fill_nmfs()` does not have a default and therefore requires a named argument, this is an example using the "crustacean" palette:
```{r, scale_fill_example, fig.height=3}
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_nmfs(palette = "crustacean", discrete = FALSE, reverse = TRUE)
```
**************
## 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.”
***** *******
<a href="https://www.fisheries.noaa.gov/"><img src="man/figures/noaa-fisheries-rgb-2line-horizontal-small.png" height=75 alt="NOAA Fisheries" />
[U.S. Department of Commerce](https://www.commerce.gov/) | [National Oceanographic and Atmospheric Administration](https://www.noaa.gov) | [NOAA Fisheries](https://www.fisheries.noaa.gov/)