Description Usage Arguments Details Value Examples
Build a "depth down" ggplot point graphic for repeated depth
profile data.
1 | ptdots_old(.dt, .x, .y, .val, ...)
|
.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 |
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:
Add mapping = aes(fill = ?) to the function call, pointing explicitly
to the data in the enclosing environment.
Pass a shape argument selecting the filled symbol shape
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.
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.
A ggplot object (S3 class defined by ggplot2)
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()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.