Simple R Package for a consistent graphic look for CBEP 2020 State of the Bay
This is a lightweight package to set up and support Casco Bay Estuary Partnership (CBEP) technical graphic standards for the 2020 State of the Bay (SotB).
Functions included in this package can be called in R Notebooks generating draft graphics for transmittal to the SotB designer. Editing specifications in this package will affect the look of all (or almost all) State of the Bay technical graphics generated after any changes are made.
The workhorse functions include:
cbep_colors()
cbep_colors2()
load_cbep_fonts()
theme_cbep()
set_cbep_default_theme()
The two color functions return a vector of six colors (as hex strings) that relate well to CBEP design standards. They differ only in the order in which the colors are presented. The first function presents them so that sequential colors contrast strongly. The second lists colors ordered from darkest to lightest. The results of calling these functions (e.g., cbep_colors(), not "cbep_colors") can be passed to many geoms (as a mapping) or to color and fill scales as is. Alternatively, specific colors can be pased to a geom as a formal parameter by indexing.
The font function checks to see if necessary fonts are loaded into the R font database and installs and loads them as necessary. This function depends on the extrafont package.
Winston Chang, (2014). extrafont: Tools for using fonts. R package version 0.17. https://CRAN.R-project.org/package=extrafont
The theme functions create a theme for use with ggplot graphics. The theme is based on theme_tufte()from the ggthemes package. The theme_tufte() is modified to use the CBEP preferred font (Montserrat, at this writing), and increase the size of the base font slightly.
The first theme function just defines the theme, and can be used as a drop-in for any other ggplot theme. The second function establishes that theme as the ggplot default theme, so you don't have to specify that for each graphic in a script for markdown file.
These two functions requires both ggplot2 and ggthemes to be available.
H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2016.
Jeffrey B. Arnold (2019). ggthemes: Extra Themes, Scales and Geoms for 'ggplot2'. R package version 4.2.0. https://CRAN.R-project.org/package=ggthemes
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.