| Title: | Stratigraphic Data Processing and Section Plots |
|---|---|
| Description: | Data processing and generating stratigraphic sections for volcanic deposits and tephrastratigraphy. Package was developed for studies on Alaska volcanoes ("av") where stratigraphic ("strat") figures are needed for interpreting eruptive histories, but the methods are applicable to any sediment stratigraphy project. Plotting styles inspired by "SedLog" (Zervas et al. 2009) <doi:10.1016/j.cageo.2009.02.009> but with more customizable outputs and flexible data input based on best practice recommendations for the tephra community (Wallace et al. 2022) <doi:10.1038/s41597-022-01515-y>. |
| Authors: | Matthew Loewen [aut, cre] (ORCID: <https://orcid.org/0000-0002-5621-285X>) |
| Maintainer: | Matthew Loewen <[email protected]> |
| License: | CC0 |
| Version: | 0.1.1.9001 |
| Built: | 2026-06-07 07:25:53 UTC |
| Source: | https://github.com/mwloewen/avstrat |
add_depths() takes a data frame of stratigraphic layer information and
calculates standardized thickness and depth values. It ensures required
columns are present, converts thickness and depth units to centimeters,
derives a plotting thickness, and computes top, bottom, and middle depths
for each layer within a stratigraphic section. The function is designed to
handle input where layers are defined either by order and thickness or with
absolute start and stop depth values.
add_depths(df)add_depths(df)
df |
A data frame containing stratigraphic layer information. The following columns are required depending on the method: Always required
If
If
Other columns are carried through unchanged. Missing expected columns are
added automatically and filled with |
The function groups data by stratsection_name and orders layers according
to stratlayer_order_start_at_top. Depths are computed cumulatively if only
thickness is provided, or taken directly from absolute depth columns if
available.
A tibble with the original data plus:
thickness_min_cm, thickness_max_cm: thickness values converted to cm.
depth_top_cm, depth_bottom_cm: depth values converted to cm.
thickness_plot: representative thickness used for plotting.
thickness_plot_warning: message if no thickness was available.
Depth_top, Depth_bottom, Depth_middle: calculated depths (cm).
Rows without sufficient information are dropped.
# Example data is included with the package data("example_data_strat", package = "avstrat") # Order + thickness method (section "fake1") df1 <- subset(example_data_strat, stratsection_name == "fake1") add_depths(df1) # Start/stop depth method (section "fake3") df2 <- subset(example_data_strat, stratsection_name == "fake3") add_depths(df2)# Example data is included with the package data("example_data_strat", package = "avstrat") # Order + thickness method (section "fake1") df1 <- subset(example_data_strat, stratsection_name == "fake1") add_depths(df1) # Start/stop depth method (section "fake3") df2 <- subset(example_data_strat, stratsection_name == "fake3") add_depths(df2)
add_layer_width() reshapes stratigraphic layer grainsize data into a "long"
format suitable for plotting polygons in a stratigraphic section diagram. It
constructs left/right grain size boundaries, gathers them into long format,
assigns depth coordinates, and converts grain size text labels into numeric
values for plotting with ggstrat().
add_layer_width(df, grainsize_direction = c("increasing", "decreasing"))add_layer_width(df, grainsize_direction = c("increasing", "decreasing"))
df |
A data frame containing stratigraphic layer information. The following columns are required:
Grain size values must be chosen from the validated list (White & Houghton, 2006, Geology 34:677–680):
Several legacy abbreviations (e.g. |
grainsize_direction |
Character string, one of
Increasing will show coarser units as bigger polygons (more prominent) which is espeically useful for emphasizing more energentic volcanic deposits. Decreasing will show finer (typically more resistive) units as bigger which may better match observed erosional profiles. |
A tibble in long format with original data plus:
size_loc: identifier for polygon vertex locations.
size_text: original grain size text.
depth: numeric depth coordinate.
grainsize: numeric grain size code for plotting.
library(dplyr) library(tidyr) df <- tidyr::tibble( stratlayer_order = c(1,2), grainsize_top = c("clay", "coarse sand/ash"), grainsize_bottom = c( "silt", "medium sand/ash"), Depth_top = c(0, 10), Depth_bottom = c(10, 20) ) add_layer_width(df)library(dplyr) library(tidyr) df <- tidyr::tibble( stratlayer_order = c(1,2), grainsize_top = c("clay", "coarse sand/ash"), grainsize_bottom = c( "silt", "medium sand/ash"), Depth_top = c(0, 10), Depth_bottom = c(10, 20) ) add_layer_width(df)
A dataset created by loading example inputs with load_stratdata_indiv().
This demonstrates the structure of stratigraphic data when stations, sections,
layers, and samples are provided as separate tables and then merged. It shares
many column definitions with example_data_strat but contains a
reduced set of fields.
example_data_indivexample_data_indiv
example_data_indivA data frame with 244 rows and 23 columns:
Character. Name/identifier of the stratigraphic section.
Character. Name/identifier of the stratigraphic layer.
Character. Free‑text description of the layer.
Integer. Order of the layer within the section.
Character. Units for thickness (e.g., "millimeters", "centimeters", "meters").
Numeric. Typical thickness of the layer.
Numeric. Minimum thickness of the layer.
Numeric. Maximum thickness of the layer.
Character. Units for depth (see thickness_units).
Numeric. Absolute depth to the top of the layer.
Numeric. Absolute depth to the bottom of the layer.
Character/Factor. Lithology or depositional type of the layer (e.g., "tephra fall", "soil").
Character. Color description.
Numeric/Character. Grain size at the top of the layer.
Numeric/Character. Grain size at the bottom of the layer.
Character. Source volcano name. If multiple, separated by "|".
Character. Station identifier (links back to station metadata).
Character. Method used for stratigraphic measurement.
Logical. Whether ordering starts at the top.
Numeric. Latitude in decimal degrees.
Numeric. Longitude in decimal degrees.
Character. Collapsed sample identifiers per layer, separated by "|".
List. Nested list column of sample IDs per layer.
example_data_strat for a more complete dataset
including additional descriptive fields.
A dataset of forms loaded with load_geodiva_forms().
Useful for demonstrating plotting and analysis functions in this package.
example_data_stratexample_data_strat
example_data_stratA data frame with 244 rows and 39 columns:
Character. Name/identifier of the stratigraphic section.
Character. Name/identifier of the stratigraphic layer.
Date. Date the section was described.
Character. Time zone of the description date.
Character. Free‑text description of the layer.
Integer. Order of the layer within the section.
Character. Units for thickness (e.g., "millimeters", "centimeters", "meters").
Numeric. Typical thickness of the layer.
Numeric. Minimum thickness of the layer.
Numeric. Maximum thickness of the layer.
Character. Units for depth (see thickness_units).
Numeric. Absolute depth to the top of the layer.
Numeric. Absolute depth to the bottom of the layer.
Numeric. Uncertainty in top depth.
Numeric. Uncertainty in bottom depth.
Character/Factor. Lithology or depositional type of the layer (e.g., "tephra fall", "soil").
Character. Color description.
Numeric/Character. Grain size at the top of the layer.
Numeric/Character. Grain size at the bottom of the layer.
Character. Grading description (e.g. normal, reverse).
Character. Description of the lower contact.
Character. Description of the upper contact.
Character. Sorting description.
Character. Support description (matrix or clast).
Numeric/Character. Tephra concentration.
Character. Stratigraphic unit designation.
Character. Formal tephra name.
Character. Tentative tephra identification.
Character. Source volcano name. If multiple source volcanoes separated by "|".
Character. Source eruption name.
Character. Sample identifier. If multiple samples separated by "|".
Character. Station identifier.
Character. Method used for stratigraphic measurement.
Logical. Whether ordering starts at the top.
Character. Free‑text notes about the section.
Numeric. Latitude in decimal degrees.
Numeric. Longitude in decimal degrees.
Character. Location description.
List. Nested list column of sample IDs per layer.
<doi.org/10.14509/31084>
<doi.org/10.14509/31090>
extract_sample_depths() takes a stratigraphic dataset that has already been merged
(e.g. from load_geodiva_forms() or load_stratdata_indiv()) and
applies add_depths() to compute absolute depths. It then expands a
nested sample column (by default "SampleID") so that each sample is
represented as its own row, and drops rows where the chosen column is
missing. Optionally, you can strip away all other layer metadata and
return only the sample IDs and depth columns. Can be used on any nested or
unested column.
extract_sample_depths( strat_data, sample_column = "SampleID", remove_layer_metadata = FALSE )extract_sample_depths( strat_data, sample_column = "SampleID", remove_layer_metadata = FALSE )
strat_data |
A data frame ready for applying |
sample_column |
A string giving the name of the column to extract
and unnest. Defaults to |
remove_layer_metadata |
Logical. If |
A data frame with one row per sample, including the depth
information and associated layer metadata (unless
remove_layer_metadata = TRUE).
# Default: expand the SampleID column extract_sample_depths(example_data_strat) # Expand a different column (here "stratlayer_sample") extract_sample_depths(example_data_strat, sample_column = "stratlayer_sample") # Return only SampleID and depth columns extract_sample_depths(example_data_strat, remove_layer_metadata = TRUE)# Default: expand the SampleID column extract_sample_depths(example_data_strat) # Expand a different column (here "stratlayer_sample") extract_sample_depths(example_data_strat, sample_column = "stratlayer_sample") # Return only SampleID and depth columns extract_sample_depths(example_data_strat, remove_layer_metadata = TRUE)
Uses ggplot2 to create a grainsize vs. depth stratigraphic section plot.
ggstrat( df, section_name, grainsize_direction = c("increasing", "decreasing"), grainsize_labs = gs_volc_abbr, use_theme = NULL, xlim = c(-1, 10), ylim = NULL, depth_units = c("cm", "m"), ybreaks = 7, layer_fill = "layer_type", layer_fill_color = "stratpal_rpg", layer_border_color = "black", layer_border_linewidth = 0.2 )ggstrat( df, section_name, grainsize_direction = c("increasing", "decreasing"), grainsize_labs = gs_volc_abbr, use_theme = NULL, xlim = c(-1, 10), ylim = NULL, depth_units = c("cm", "m"), ybreaks = 7, layer_fill = "layer_type", layer_fill_color = "stratpal_rpg", layer_border_color = "black", layer_border_linewidth = 0.2 )
df |
A data frame containing stratigraphic data.
Must include columns |
section_name |
Character string giving the section name to filter "stratsection_name". |
grainsize_direction |
Character string, one of
Increasing will show coarser units as bigger polygons (more prominent) which is espeically useful for emphasizing more energentic volcanic deposits. Decreasing will show finer (typically more resistive) units as bigger which may better match observed erosional profiles. |
grainsize_labs |
Character vector of labels for the x-axis. Several predefined options are available:
|
use_theme |
A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat". |
xlim |
Numeric vector of length 2 giving x-axis limits. |
ylim |
Numeric vector of length 2 giving y-axis limits (optional). |
depth_units |
Units to use for depth (y-axis) scale, either "cm" (default) or "m". |
ybreaks |
Number of breaks on the y-axis. |
layer_fill |
Character string naming the column to use for fill. If using anything other than "layer_type" from the template, will need to make a new palette. |
layer_fill_color |
Palette object to use for fill colors. |
layer_border_color |
Border color for polygons. |
layer_border_linewidth |
Border line width for polygons. |
A ggplot object
example_data_strat |> add_depths() |> ggstrat(section_name = "21LSHD02")example_data_strat |> add_depths() |> ggstrat(section_name = "21LSHD02")
Generate and save a series of stratigraphic plots, one per unique stratigraphic section in the input data frame. The user can supply any plotting function that returns a ggplot object (e.g. one of the package's plotting functions, or a custom function).
ggstrat_bulk_save( df, plotfunction = ggstrat, outdir = NULL, file_type = "png", dpi = 300, width = 4, height = 8, units = "in", ask = TRUE, ... )ggstrat_bulk_save( df, plotfunction = ggstrat, outdir = NULL, file_type = "png", dpi = 300, width = 4, height = 8, units = "in", ask = TRUE, ... )
df |
A data frame containing stratigraphic data.
Must include columns |
plotfunction |
A function that generates a plot for a single
section. It should accept at least two arguments: the full data
frame ( |
outdir |
Directory where plots will be saved. Suggest supplying a name
such as |
file_type |
File extension for saved plots (e.g. |
dpi |
Plot resolution in dots per inch. Can be a numeric value
(e.g. |
width |
Plot width passed to |
height |
Plot height passed to |
units |
Units for |
ask |
Logical. If |
... |
Additional arguments passed on to |
Invisibly returns NULL. Called for its side effect of
saving plot files to disk.
# Save plots for each section using the default ggstrat() function td <- tempdir() ggstrat_bulk_save(example_data_strat, outdir = td) # Save plots using a different plotting function ggstrat_bulk_save(example_data_strat, plotfunction = ggstrat_column, outdir = td) # Save plots with higher resolution ggstrat_bulk_save(example_data_strat, outdir = td, dpi = 600) # Optional cleanup unlink(list.files(td, full.names = TRUE))# Save plots for each section using the default ggstrat() function td <- tempdir() ggstrat_bulk_save(example_data_strat, outdir = td) # Save plots using a different plotting function ggstrat_bulk_save(example_data_strat, plotfunction = ggstrat_column, outdir = td) # Save plots with higher resolution ggstrat_bulk_save(example_data_strat, outdir = td, dpi = 600) # Optional cleanup unlink(list.files(td, full.names = TRUE))
Uses ggplot2 to create a simple depth-only stratigraphic section plot with no variable mapped to the x-axis. Each layer is drawn as a fixed-width rectangle.
ggstrat_column( df, section_name, use_theme = NULL, ylim = NULL, depth_units = c("cm", "m"), ybreaks = 7, layer_fill = "layer_type", layer_fill_color = "stratpal_rpg", layer_border_color = "black", layer_border_linewidth = 0.2 )ggstrat_column( df, section_name, use_theme = NULL, ylim = NULL, depth_units = c("cm", "m"), ybreaks = 7, layer_fill = "layer_type", layer_fill_color = "stratpal_rpg", layer_border_color = "black", layer_border_linewidth = 0.2 )
df |
A data frame containing stratigraphic data.
Must include columns |
section_name |
Character string giving the section name to filter "stratsection_name". |
use_theme |
A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat". |
ylim |
Numeric vector of length 2 giving y-axis limits (optional). |
depth_units |
Units to use for depth (y-axis) scale, either "cm" (default) or "m". |
ybreaks |
Number of breaks on the y-axis. |
layer_fill |
Character string naming the column to use for fill. If using anything other than "layer_type" from the template, will need to make a new palette. |
layer_fill_color |
Palette object to use for fill colors. |
layer_border_color |
Border color for polygons. |
layer_border_linewidth |
Border line width for polygons. |
A ggplot object showing a schematic stratigraphic column.
example_data_strat |> ggstrat_column(section_name = "21LSHD02")example_data_strat |> ggstrat_column(section_name = "21LSHD02")
Uses ggplot2 to plot any character column associated with stratigraphic data
such as SampleID at the correct depths for their corresponding
layers. Connecting lines extend to the left of the plot to point to plotted
layers. It is designed to be combined with a stratigraphic section plot created by
ggstrat() using the patchwork::patchwork framework for arranging multiple
ggplot objects.
ggstrat_label( df, section_name, use_theme = NULL, label = "stratlayer_sample", ylim = NULL, ybreaks = 7 )ggstrat_label( df, section_name, use_theme = NULL, label = "stratlayer_sample", ylim = NULL, ybreaks = 7 )
df |
A data frame containing stratigraphic data.
Must include columns |
section_name |
Character string giving the section name to filter "stratsection_name". |
use_theme |
A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat". |
label |
Character strin gnaming the column to use for labels. Default is "SampleID". |
ylim |
Numeric vector of length 2 giving y-axis limits (optional). |
ybreaks |
Number of breaks on the y-axis. |
A ggplot object showing SampleIDs plotted by depth in section.
# Example 1: Basic usage example_data_strat |> ggstrat_label(section_name = "21LSHD02", label = "SampleID") # Example 2: Combine with a stratigraphic section plot using patchwork if (requireNamespace("patchwork", quietly = TRUE)) { stratsection <- example_data_strat |> ggstrat(section_name = "21LSHD02") samples <- example_data_strat |> ggstrat_label(section_name = "21LSHD02", label = "SampleID") stratsection + samples }# Example 1: Basic usage example_data_strat |> ggstrat_label(section_name = "21LSHD02", label = "SampleID") # Example 2: Combine with a stratigraphic section plot using patchwork if (requireNamespace("patchwork", quietly = TRUE)) { stratsection <- example_data_strat |> ggstrat(section_name = "21LSHD02") samples <- example_data_strat |> ggstrat_label(section_name = "21LSHD02", label = "SampleID") stratsection + samples }
Combines a grainsize–depth plot and sample label plot into a single composite figure using the patchwork::patchwork framework. The two plots are aligned and legends are collected at the bottom.
ggstrat_samples( df, section_name, label = "stratlayer_sample", use_theme = NULL, ylim = NULL, depth_units = c("cm", "m"), ybreaks = 7 )ggstrat_samples( df, section_name, label = "stratlayer_sample", use_theme = NULL, ylim = NULL, depth_units = c("cm", "m"), ybreaks = 7 )
df |
A data frame containing stratigraphic data.
Must include columns |
section_name |
Character string giving the section name to filter "stratsection_name". |
label |
Character strin gnaming the column to use for labels. Default is "SampleID". |
use_theme |
A ggplot2 theme object to apply to the plot, e.g., "theme_avstrat". |
ylim |
Numeric vector of length 2 giving y-axis limits (optional). |
depth_units |
Units to use for depth (y-axis) scale, either "cm" (default) or "m". |
ybreaks |
Number of breaks on the y-axis. |
A patchwork/ggplot object combining the stratigraphic plot
and sample labels. This object can be further modified with
ggplot2::theme() or additional patchwork operators.
example_data_strat |> ggstrat_samples(section_name = "21LSHD02")example_data_strat |> ggstrat_samples(section_name = "21LSHD02")
load_geodiva_forms() processes and cleans stratigraphic data from GeoDIVA
upload forms, specifically a form that includes Station and Sample data and
another form that includes the Layer data. It merges these datasets,
resolves any conflicts in key fields, and prepares a consolidated dataset
for further analysis. The function also extracts and, optionally, prints a
list of unique stratigraphic sections.
load_geodiva_forms(station_sample_upload, layer_upload, verbose = TRUE)load_geodiva_forms(station_sample_upload, layer_upload, verbose = TRUE)
station_sample_upload |
data frame created from uploaded GeoDIVA format
Station/Sample upload sheet, usually uploaded with |
layer_upload |
data frame created from uploaded GeoDIVA format
Layers upload sheet, usually uploaded with |
verbose |
Logical. If TRUE (default), prints a message listing the imported stratigraphic sections. Set to FALSE to suppress console output. |
A data frame containing the merged and cleaned stratigraphic data, ready for further analysis.
# Locate the example Excel files shipped with the package path_samples <- system.file("extdata", "example_samples_stations_upload_2024.xlsx", package = "avstrat" ) path_layers <- system.file("extdata", "example_layers_upload_2024.xlsx", package = "avstrat" ) # Read them with readxl library(readxl) station_sample_upload <- readxl::read_xlsx(path_samples, sheet = "Data") layer_upload <- readxl::read_xlsx(path_layers, sheet = "Data") result <- load_geodiva_forms(station_sample_upload, layer_upload) head(result) # result is a data frame# Locate the example Excel files shipped with the package path_samples <- system.file("extdata", "example_samples_stations_upload_2024.xlsx", package = "avstrat" ) path_layers <- system.file("extdata", "example_layers_upload_2024.xlsx", package = "avstrat" ) # Read them with readxl library(readxl) station_sample_upload <- readxl::read_xlsx(path_samples, sheet = "Data") layer_upload <- readxl::read_xlsx(path_layers, sheet = "Data") result <- load_geodiva_forms(station_sample_upload, layer_upload) head(result) # result is a data frame
load_stratdata_indiv() loads necessary data for avstrat from separate
station (location), section (section metadata), stratlayer, and sample data.
Allows upload of smaller number of tables if data are already joined together
(e.g., stations-sections combined, or layers-samples combined). The function
also extracts and, optionally, prints a list of unique stratigraphic sections.
load_stratdata_indiv( stations_upload, sections_upload, layers_upload, samples_upload = NULL, verbose = TRUE )load_stratdata_indiv( stations_upload, sections_upload, layers_upload, samples_upload = NULL, verbose = TRUE )
stations_upload |
A data frame with "station" metadata. The
following columns are required in order to work with
|
sections_upload |
A data frame with "section" metadata (point to same
file as station_upload if already joined). The following columns are required
in order to work with
|
layers_upload |
A data frame with "layer" metadata. The following columns are required
in order to work with
Grain size values must be chosen from the validated list (White & Houghton, 2006, Geology 34:677–680):
If
|
samples_upload |
A data frame with "sample" metadata.
|
verbose |
Logical. If TRUE (default), prints a message listing the imported stratigraphic sections. Set to FALSE to suppress console output. |
A data frame of layers joined with section and station metadata, plus collapsed sample information:
stratlayer_sample: concatenated SampleIDs per layer (separated by "|").
SampleID: list column of SampleIDs per layer.
# Locate the example Excel files shipped with the package path <- system.file("extdata", "example_inputs.xlsx", package = "avstrat" ) # Read them with readxl library(readxl) stations <- readxl::read_xlsx(path, sheet = "stations") sections <- readxl::read_xlsx(path, sheet = "sections") layers <- readxl::read_xlsx(path, sheet = "layers") samples <- readxl::read_xlsx(path, sheet = "samples_layer") load_stratdata_indiv(stations_upload = stations, sections_upload = sections, layers_upload = layers, samples_upload = samples)# Locate the example Excel files shipped with the package path <- system.file("extdata", "example_inputs.xlsx", package = "avstrat" ) # Read them with readxl library(readxl) stations <- readxl::read_xlsx(path, sheet = "stations") sections <- readxl::read_xlsx(path, sheet = "sections") layers <- readxl::read_xlsx(path, sheet = "layers") samples <- readxl::read_xlsx(path, sheet = "samples_layer") load_stratdata_indiv(stations_upload = stations, sections_upload = sections, layers_upload = layers, samples_upload = samples)
This function launches a Shiny app that displays an interactive map locations
with stratigraphic data. If you click on a station it will generate a stratigraphic
plot with the plotting function of your choice (default is ggstrat_samples()).
You can also adjust the height of the plot using the slider below the map.
run_ggstrat_app(df, plot_fun = ggstrat_samples)run_ggstrat_app(df, plot_fun = ggstrat_samples)
df |
A data frame containing stratigraphic data. |
plot_fun |
A function that generates a stratigraphic plot.
Defaults to |
A Shiny app object.
if (interactive()) { # Use your default plotting function run_ggstrat_app(example_data_strat) # Or swap in a custom plotting function run_ggstrat_app(example_data_strat, plot_fun = ggstrat_column) }if (interactive()) { # Use your default plotting function run_ggstrat_app(example_data_strat) # Or swap in a custom plotting function run_ggstrat_app(example_data_strat, plot_fun = ggstrat_column) }
A ggplot2 fill scale that uses one of the built-in stratigraphic palettes.
scale_fill_stratpal( palette = c("stratpal_rpg", "stratpal_grays"), overrides = NULL, allow_na = FALSE, na_color = "gray90", ... )scale_fill_stratpal( palette = c("stratpal_rpg", "stratpal_grays"), overrides = NULL, allow_na = FALSE, na_color = "gray90", ... )
palette |
Character string naming which palette to use.
Options are names of palettes in |
overrides |
Optional named character vector of colors to override entries in the chosen palette. |
allow_na |
Logical. If TRUE, missing categories are filled with
|
na_color |
Color to use for missing categories when
|
... |
Additional arguments passed to |
A ggplot2 scale object.
library(ggplot2) ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) + geom_bar() + scale_fill_stratpal("stratpal_rpg") # Override one color scale_fill_stratpal("stratpal_rpg", overrides = c("volcanic" = "orange")) # Allow missing categories to be filled with gray scale_fill_stratpal("stratpal_grays", allow_na = TRUE)library(ggplot2) ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) + geom_bar() + scale_fill_stratpal("stratpal_rpg") # Override one color scale_fill_stratpal("stratpal_rpg", overrides = c("volcanic" = "orange")) # Allow missing categories to be filled with gray scale_fill_stratpal("stratpal_grays", allow_na = TRUE)
Named character vectors of hex colors for stratigraphic plotting.
These palettes can be passed to scale_fill_stratpal().
stratpal_rpg stratpal_graysstratpal_rpg stratpal_grays
Named character vectors
An object of class character of length 30.
An object of class character of length 30.
stratpal_rpg["volcanic"] stratpal_grays["soil"]stratpal_rpg["volcanic"] stratpal_grays["soil"]
A ggplot2 theme designed to work well with typical plot ouput from avstrat, and matching the author's preferred aesthetics.
theme_avstrat(base_size = 11)theme_avstrat(base_size = 11)
base_size |
Base font size. Defaults to 11. |
A ggplot2::theme() object.
# Apply a custom theme to one plot ggstrat(df = example_data_strat, section_name = "21LSHD02") + theme_avstrat() # Set the custom theme as default for all plots ggplot2::theme_set(theme_avstrat()) ggstrat(df = example_data_strat, section_name = "21LSHD02")# Apply a custom theme to one plot ggstrat(df = example_data_strat, section_name = "21LSHD02") + theme_avstrat() # Set the custom theme as default for all plots ggplot2::theme_set(theme_avstrat()) ggstrat(df = example_data_strat, section_name = "21LSHD02")
Ensures that a palette covers all required categories. By default,
missing categories trigger an error. If allow_na = TRUE, missing
categories are filled with a default color instead.
validate_stratpal(pal, allow_na = FALSE, na_color = "gray90")validate_stratpal(pal, allow_na = FALSE, na_color = "gray90")
pal |
Named character vector of colors. |
allow_na |
Logical. If TRUE, missing categories are filled with
|
na_color |
Color to use for missing categories when
|
A complete palette (named character vector) ordered to match the required categories.
# A complete palette passes validation validate_stratpal(stratpal_rpg) # Allow missing categories to be filled with gray validate_stratpal(stratpal_grays, allow_na = TRUE)# A complete palette passes validation validate_stratpal(stratpal_rpg) # Allow missing categories to be filled with gray validate_stratpal(stratpal_grays, allow_na = TRUE)