Learn R Programming

avstrat (version 0.1.1)

ggstrat_label: Plots text lables alongside a stratigraphic section

Description

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.

Usage

ggstrat_label(
  df,
  section_name,
  use_theme = NULL,
  label = "stratlayer_sample",
  ylim = NULL,
  ybreaks = 7
)

Value

A ggplot object showing SampleIDs plotted by depth in section.

Arguments

df

A data frame containing stratigraphic data. Must include columns stratsection_name, stratlayer_order, grainsize, depth, and the column specified by layer_fill.

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.

Examples

Run this code
# 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
}

Run the code above in your browser using DataLab