Title: | Washington Soil Health Initiative Branding |
---|---|
Description: | Create plots and tables in a consistent style with WaSHI (Washington Soil Health Initiative) branding. Use 'washi' to easily style your 'ggplot2' plots and 'flextable' tables. |
Authors: | Jadey Ryan [aut, cre], Molly McIlquham [aut], Dani Gelardi [aut], Washington State Department of Agriculture [cph, fnd] |
Maintainer: | Jadey Ryan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0.9000 |
Built: | 2024-11-21 03:50:05 UTC |
Source: | https://github.com/WA-Department-of-Agriculture/washi |
A subset WaSHI State of the Soils Assessment dataset that has been anonymized. This dataset is tidied, so each measurement is in its own row.
example_data_long
example_data_long
example_data_long
A data frame with 1,800 rows and 14 columns:Year of sample
Anonymized IDs
Anonymized names
Truncated coordinates
Measured soil texture
Measurement name with units
Measurement result
...
https://agr.wa.gov/departments/land-and-water/natural-resources/soil-health/state-of-the-soils
A subset WaSHI State of the Soils Assessment dataset that has been anonymized. This dataset presents each sample in its own row, with columns for each measurement.
example_data_wide
example_data_wide
example_data_wide
A data frame with 30 rows and 72columns:
Year of sample
Anonymized IDs
Anonymized names
Truncated coordinates
Measured soil texture
Column name includes measurement and units; value is the measurement results
...
https://agr.wa.gov/departments/land-and-water/natural-resources/soil-health/state-of-the-soils
Creates a flextable in WaSHI's style.
washi_flextable( data, cols_bold = NULL, header_font = "Lato", body_font = "Poppins", header_font_color = "white", header_bg_color = washi_pal[["standard"]][["green"]], border_color = washi_pal[["standard"]][["tan"]] )
washi_flextable( data, cols_bold = NULL, header_font = "Lato", body_font = "Poppins", header_font_color = "white", header_bg_color = washi_pal[["standard"]][["green"]], border_color = washi_pal[["standard"]][["tan"]] )
data |
Dataframe for the table. |
cols_bold |
Numeric indices of columns to bold. Defaults to
|
header_font |
Font family for header text. Defaults to "Lato". |
body_font |
Font family for table body text. Defaults to "Poppins". |
header_font_color |
Hexcode color for header font. Defaults to white. |
header_bg_color |
Hexcode color for header background. Defaults to WaSHI green. |
border_color |
Hexcode color for horizontal borders. Defaults to WaSHI tan. |
A flextable formatted in WaSHI's style.
subset( example_data_wide, select = c( "sampleId", "county", "crop", "totalN_%", "totalC_%" ) ) |> washi_flextable(cols_bold = 1)
subset( example_data_wide, select = c( "sampleId", "county", "crop", "totalN_%", "totalC_%" ) ) |> washi_flextable(cols_bold = 1)
Opens the font files to install on your computer.
washi_install_fonts()
washi_install_fonts()
Opens a directory containing font files.
Color palettes are stored in a named list.
washi_pal
washi_pal
An object of class list
of length 11.
List of available washi
color palettes
Other color palette functions:
washi_pal_setup()
,
washi_pal_view()
# List names of available palettes names(washi_pal) # Get hex codes from a palette using dollar `$name` or # double bracket # `[["name"]]` operators for extracting list elements washi_pal$standard washi_pal[["green_gradient"]] # Extract a color from the standard WaSHI palette washi_pal[["standard"]][["green"]]
# List names of available palettes names(washi_pal) # Get hex codes from a palette using dollar `$name` or # double bracket # `[["name"]]` operators for extracting list elements washi_pal$standard washi_pal[["green_gradient"]] # Extract a color from the standard WaSHI palette washi_pal[["standard"]][["green"]]
Choose desired number of colors and whether the colors are reversed.
washi_pal_setup(palette = "standard", n, reverse = FALSE)
washi_pal_setup(palette = "standard", n, reverse = FALSE)
palette |
Character name of palette in washi_pal. See
|
n |
Number of colors in palette. |
reverse |
Boolean indicating whether the palette should be reversed. Default is FALSE. |
A vector of color hex codes.
Other color palette functions:
washi_pal_view()
,
washi_pal
washi_pal_setup("color_blind") washi_pal_setup("green_gradient", 12)
washi_pal_setup("color_blind") washi_pal_setup("green_gradient", 12)
Show the colors within a palette in a plot.
washi_pal_view(palette = "color_blind", n, reverse = FALSE)
washi_pal_view(palette = "color_blind", n, reverse = FALSE)
palette |
Character name of palette in washi_pal. See
|
n |
Number of colors in palette. |
reverse |
Boolean indicating whether the palette should be reversed. Default is FALSE. |
A plot with each color displayed.
Other color palette functions:
washi_pal_setup()
,
washi_pal
washi_pal_view("standard") washi_pal_view("color_blind") washi_pal_view("blue_gradient", 4, reverse = TRUE)
washi_pal_view("standard") washi_pal_view("color_blind") washi_pal_view("blue_gradient", 4, reverse = TRUE)
Provides compatibility with ggplot2
.
washi_scale( palette = "color_blind", aesthetics = c("color", "fill"), alpha = 1, reverse = FALSE, discrete = TRUE, ... )
washi_scale( palette = "color_blind", aesthetics = c("color", "fill"), alpha = 1, reverse = FALSE, discrete = TRUE, ... )
palette |
Character name of palette in washi_pal. See
|
aesthetics |
Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. Defaults to c("color", "fill"), which applies the palette to both the color and fill aesthetics at the same time. |
alpha |
Numeric transparency level of the color from 0 to 1. Default is 1 (not transparent). |
reverse |
Boolean indicating whether the palette should be reversed. Default is FALSE. |
discrete |
Boolean indicating whether color aesthetic is discrete or not. Default is TRUE. |
... |
Additional arguments passed to discrete_scale() or scale_color_gradientn(), used respectively when discrete is TRUE or FALSE |
A ScaleContinuous
or ScaleDiscrete
object that can be
added to a ggplot
object.
Other ggplot2 functions:
washi_theme()
library(ggplot2) # Discrete scale example_data_wide |> subset(crop %in% c("Apple", "Cherry", "Potato")) |> ggplot(aes(x = pH, y = Mn_mg.kg, color = crop)) + geom_point(size = 2.5) + theme_minimal() + washi_scale() # Continuous scale example_data_wide |> ggplot(aes(x = `totalC_%`, y = poxC_mg.kg, color = poxC_mg.kg)) + geom_point(size = 2.5) + theme_minimal() + washi_scale("green_gradient", reverse = TRUE, discrete = FALSE)
library(ggplot2) # Discrete scale example_data_wide |> subset(crop %in% c("Apple", "Cherry", "Potato")) |> ggplot(aes(x = pH, y = Mn_mg.kg, color = crop)) + geom_point(size = 2.5) + theme_minimal() + washi_scale() # Continuous scale example_data_wide |> ggplot(aes(x = `totalC_%`, y = poxC_mg.kg, color = poxC_mg.kg)) + geom_point(size = 2.5) + theme_minimal() + washi_scale("green_gradient", reverse = TRUE, discrete = FALSE)
All changed defaults from this function can be overridden by another
call to ggplot2::theme()
with the desired changes.
washi_theme( header_font = "Lato Black", header_color = "#151414", body_font = "Poppins", body_color = "#151414", text_scale = 1, legend_position = "top", facet_space = 2, color_gridline = washi_pal[["standard"]][["tan"]], gridline_y = TRUE, gridline_x = TRUE, ... )
washi_theme( header_font = "Lato Black", header_color = "#151414", body_font = "Poppins", body_color = "#151414", text_scale = 1, legend_position = "top", facet_space = 2, color_gridline = washi_pal[["standard"]][["tan"]], gridline_y = TRUE, gridline_x = TRUE, ... )
header_font |
Font family for title and subtitle. Defaults to "Lato Black". |
header_color |
Font color for title and subtitle. Defaults to almost black. |
body_font |
Font family for all other text Defaults to "Poppins". |
body_color |
Font color for all other text Defaults to almost black. |
text_scale |
Scalar that will grow/shrink all text defined within. |
legend_position |
Position of legend ("none", "left", "right", "bottom", "top", or two-element numeric vector). Defaults to "top". |
facet_space |
Controls how far apart facets are from each other. |
color_gridline |
Gridline color. Defaults to WaSHI tan. |
gridline_y |
Boolean indicating whether major gridlines are displayed for the y axis. Default is TRUE. |
gridline_x |
Boolean indicating whether major gridlines are displayed for the x axis. Default is TRUE. |
... |
Pass any parameters from theme that are not already defined within. |
ggplot2
object
Adapted from glitr::si_style()
.
Other ggplot2 functions:
washi_scale()
# NOTE: These examples do not use Poppins or Lato in order to pass # automated checks on computers without these fonts installed. library(ggplot2) # Single geom_point plot example_data_wide |> subset(crop %in% c("Apple", "Cherry", "Potato")) |> ggplot(aes(x = pH, y = Mn_mg.kg, color = crop)) + labs( title = "Scatter plot of pH and Mn (mg/kg)", subtitle = "Example with geom_point().", caption = "This is a caption." ) + geom_point(size = 2.5) + washi_theme( header_font = "sans", body_font = "sans" ) + washi_scale() # Bar plot if (requireNamespace("forcats")) { example_data_wide |> ggplot(aes(x = forcats::fct_rev(forcats::fct_infreq(crop)))) + geom_bar(fill = washi_pal[["standard"]][["blue"]]) + geom_text( aes( y = after_stat(count), label = after_stat(count) ), stat = "count", hjust = 2.5, color = "white" ) + # Flip coordinates to accommodate long crop names coord_flip() + labs( title = "Number of samples in each crop", subtitle = "Example plot with geom_bar() without gridlines.", y = NULL, x = NULL ) + # Turn gridlines off washi_theme( gridline_y = FALSE, gridline_x = FALSE, header_font = "sans", body_font = "sans" ) + # Remove x-axis theme(axis.text.x = element_blank()) } # Facetted geom_density plots example_data_long |> subset(measurement %in% c("totalC_%", "poxC_mg.kg") & !texture == "Loamy Sand") |> ggplot(aes(x = value, fill = texture, color = texture)) + labs( title = "Distribution of POXC (mg/kg) and Total C (%)", subtitle = "Example with geom_density() and facet_wrap()." ) + geom_density(alpha = 0.4) + facet_wrap(. ~ measurement, scales = "free") + washi_theme( legend_position = "bottom", header_font = "sans", body_font = "sans" ) + washi_scale() + xlab(NULL) + guides(col = guide_legend(nrow = 2, byrow = TRUE))
# NOTE: These examples do not use Poppins or Lato in order to pass # automated checks on computers without these fonts installed. library(ggplot2) # Single geom_point plot example_data_wide |> subset(crop %in% c("Apple", "Cherry", "Potato")) |> ggplot(aes(x = pH, y = Mn_mg.kg, color = crop)) + labs( title = "Scatter plot of pH and Mn (mg/kg)", subtitle = "Example with geom_point().", caption = "This is a caption." ) + geom_point(size = 2.5) + washi_theme( header_font = "sans", body_font = "sans" ) + washi_scale() # Bar plot if (requireNamespace("forcats")) { example_data_wide |> ggplot(aes(x = forcats::fct_rev(forcats::fct_infreq(crop)))) + geom_bar(fill = washi_pal[["standard"]][["blue"]]) + geom_text( aes( y = after_stat(count), label = after_stat(count) ), stat = "count", hjust = 2.5, color = "white" ) + # Flip coordinates to accommodate long crop names coord_flip() + labs( title = "Number of samples in each crop", subtitle = "Example plot with geom_bar() without gridlines.", y = NULL, x = NULL ) + # Turn gridlines off washi_theme( gridline_y = FALSE, gridline_x = FALSE, header_font = "sans", body_font = "sans" ) + # Remove x-axis theme(axis.text.x = element_blank()) } # Facetted geom_density plots example_data_long |> subset(measurement %in% c("totalC_%", "poxC_mg.kg") & !texture == "Loamy Sand") |> ggplot(aes(x = value, fill = texture, color = texture)) + labs( title = "Distribution of POXC (mg/kg) and Total C (%)", subtitle = "Example with geom_density() and facet_wrap()." ) + geom_density(alpha = 0.4) + facet_wrap(. ~ measurement, scales = "free") + washi_theme( legend_position = "bottom", header_font = "sans", body_font = "sans" ) + washi_scale() + xlab(NULL) + guides(col = guide_legend(nrow = 2, byrow = TRUE))