ptdots_old: Draw repeated profile data as dots

Description Usage Arguments Details Value Examples

View source: R/ptlines_old.R

Description

Build a "depth down" ggplot point graphic for repeated depth profile data.

Usage

1
ptdots_old(.dt, .x, .y, .val, ...)

Arguments

.dt

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

.x

Value that defines the x (time) coordinate of the plot. Usually a date or other time coordinate. Can be either a vector or the name of a vector in source data frame, not an expression.

.y

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

.val

Value to be symbolized via the color of the dots. Usually a measured environmental variable that varies with water depth. Can be either a numeric vector or the name of a numeric vector in source data frame, not an expression.

...

Further arguments to pass to geom_point(). Likely to include additional aesthetic specifications. To pass additional aesthetic mappings, use mapping = aes() referring to names from the enclosing environment (not a data column name).

Details

Create a graphic that draws vertical profile data across multiple dates or times. Depth is drawn reversed so that zero is at the top and depth increases downward. Values are drawn as dots on an x (usually date or time) by y (usually depth, reversed) layout. By default, dots are symbolized by color to depict measured values.

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

Default colors from ggplot2 are seldom optimal. Users will usually want to adjust colors using scale_color_viridis_c(), scale_color_distiller(), or scale_color_continuous().

Passing the name of a vector in the data frame into a supplementary mapping = aes() call does yet not work. Any supplementary aesthetics defined in mapping = aes() must refer to names from the enclosing environment, either via an explicit reference to the data frame, or by referring to a vector defined in the enclosing environment.

As a result, this function does not yet work well with filled point symbols. (R point shapes 21 through 25). That takes several additional steps:

  1. Add mapping = aes(fill = ?) to the function call, pointing explicitly to the data in the enclosing environment.

  2. Pass a shape argument selecting the filled symbol shape

  3. Usually, pass a color argument to define the fixed dot outline color. (color = 'gray50' is often a good starting point). If you don't, ggplot2 will vary the outline color according to the value of .val, which is probably not what you want.

  4. Usually, you will want to supplement the call to this function with a cal lto scale_fill_viridis_c(), scale_fill_distiller(), or scale_fill_continuous() to define the fill color scale.

Value

A ggplot object (S3 class defined by ggplot2)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Dummy data
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))
# Normal use
ptdots_old(df, month, depth, val) +
  theme_minimal()

# Filled Symbols
ptdots_old(dep_sonde, month, depth, do, size = 5,
      shape = 21, color = 'gray25',
     mapping = aes(fill = dep_sonde$do)) +
 theme_minimal()

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