ggphase_diagram: Plot phases of a sand-clay mix

View source: R/ggphase_diagram.R

ggphase_diagramR Documentation

Plot phases of a sand-clay mix

Description

Generates a ggplot showing volumetrically accurate representations of the solid, liquid, and gaseous phases in a sand-clay mixture. Options to label the phases with or without their volume fractions.

Usage

ggphase_diagram(
  sand_pct,
  clay_pct,
  G_sa,
  G_c,
  dry_density,
  water_content,
  sand_color = "#c2b280",
  clay_color = "#643F30",
  alpha_level = 1/4,
  ambient_temp_c = 22,
  labels = TRUE,
  values = TRUE,
  base_family = NULL,
  return_data = TRUE
)

Arguments

sand_pct

percent sand by dry mass in the mixture

clay_pct

percent clay (i.e. fine-grained soil) by dry mass in the mixture

G_sa

specific gravity of sandy soil

G_c

specific gravity of clay soil

dry_density

dry bulk density in g/cm^3

water_content

gravimetric water content

sand_color

quoted string containing color name or hex code

clay_color

quoted string containing color name or hex code

alpha_level

alpha value for the shaded box areas

ambient_temp_c

temperature used to compute water volume

labels

show the identity of each phase?

values

show the percent volume occupied by each phase?

base_family

character, passed to various text-drawing arguments

return_data

logical, whether to also return a data frame

Value

list containing a ggplot object and a tibble of the phase volumes. If return_data = FALSE, the second list element is NULL

Examples

# make a diagram for each of the 5 samples in a Proctor test # note the
# subtle changes in the solid phases volume and the more severe change in
# water-filled pore space
library(magrittr)

compaction_data <- soiltestr::example_proctor_data %>%
  soiltestr::add_physical_properties()

standard_data <-
  dplyr::filter(compaction_data, compaction_effort == "standard")

args <- standard_data %>%
  dplyr::select(ambient_temp_c, water_content, dry_density) %>%
  dplyr::mutate(
    sand_pct = 0.6,
    clay_pct = 0.4,
    G_sa = 2.67,
    G_c = 2.78,
    labels = TRUE,
    values = FALSE
  )

plots <- purrr::pmap(args, ggphase_diagram)

patchwork::wrap_plots(plots, nrow = 1)

evanmascitti/soiltestr documentation built on Oct. 6, 2022, 5:32 p.m.