ptlines_old: Draw depth profiles as lines

Description Usage Arguments Details Value Examples

View source: R/ptlines_old.R

Description

Build a conventional "depth down" ggplot2 line graphic for repeated depth profile data.

Usage

1
ptlines_old(.dt, .val, .y, .grp, .sort = TRUE, ...)

Arguments

.dt

Data frame containing data to plot. Can be NULL, if all data vectors are found in the enclosing environment.

.val

Value that defines the x coordinate of the plot. Usually a measured quantity. Either a numeric vector or name of a numeric vector from the source data frame (unquoted or quoted)

.y

Value that defines the (reversed) y coordinate of the plot. Usually the depth coordinate. Can be either a numeric vector or the name of a numeric vector in source data frame (unquoted or quoted)

.grp

Factor or character vector, name of a factor or character vector in the source data frame, or an expression that evaluates (with data masking) to a character or factor vector. Usually a date.

.sort

TRUE / FALSE. Should data be sorted by .y variable before plotting? This is almost always what you want to generate clean traces for each profile.

...

Other arguments to pass to geom_path(). Likely to include additional aesthetics. To pass additional aesthetic mappings, use mapping = aes().

Details

Depth profiles are drawn as lines, with depth on a reversed vertical axis, so that zero is at the top and depth increases downward. Values of a measured variable increase along the X axis. Multiple profiles (often dates or times) are drawn as separate lines, coded by color. The argument that defines those groups should be a factor or character vector.

The function's first parameter is a data frame, and it produces a ggplot2 plot object, so can be integrated into ggplot2 andtidyverse work flows.

Value

A ggplot object (S3 class defined by ggplot2)

Examples

1
2
3
4
5
6
df <- tibble::tibble(depth = rep(1:10,3),
                month = factor(rep(c(6,7,8),each = 10),
                                 labels = c('Jun', 'Jul', 'Aug')),
                val = (depth+50)/5 - 5 + rnorm(30, 0, 0.25))
ptlines_old(df, val, depth, month) +
  theme_minimal()

ccb60/tdggraph documentation built on Dec. 19, 2021, 1:58 p.m.