Positioning discrete time points (e.g. months) on a continuous time scale (e.g. days) is indeterminate - which day should represent a month? This is resolved by aligning each time point within its granularity, where 0 is start alignment, 1 is end alignment, and 0.5 is center alignment.

aes_nudge(
  center = 0.5,
  left = 0,
  right = 1,
  x = center,
  xmin = left,
  xmax = right,
  xend = center,
  xintercept = center,
  xmin_final = left,
  xmax_final = right,
  xlower = left,
  xmiddle = center,
  xupper = right,
  x0 = center,
  y = center,
  ymin = left,
  ymax = right,
  yend = center,
  yintercept = center,
  ymin_final = left,
  ymax_final = right,
  ylower = left,
  ymiddle = center,
  yupper = right,
  y0 = center
)

Arguments

center, left, right

Alignment applied to centered (e.g. x, xend), lower (e.g. xmin, xlower), and upper (e.g. xmax, xupper) positional aesthetics respectively. Setting these changes the default for all semantically equivalent aesthetics below.

x, xmin, xmax, xend, xintercept, xmin_final, xmax_final, xlower, xmiddle, xupper, x0

Alignment for individual x aesthetics.

y, ymin, ymax, yend, yintercept, ymin_final, ymax_final, ylower, ymiddle, yupper, y0

Alignment for individual y aesthetics.

Value

A function that takes an aesthetic name and returns its alignment, suitable for the align_discrete argument of scale_x_mixtime().

Details

Different positional aesthetics often require different alignments. A ribbon spanning a month should start at the beginning of the month and end at the end of it, while a line should pass through its center. aes_nudge() specifies these alignments per aesthetic, and is passed to the align_discrete argument of scale_x_mixtime().

Examples

# Center aligned points, with intervals spanning the full granularity
aes_nudge(center = 0.5, left = 0, right = 1)
#> function (aesthetic) 
#> {
#>     offsets[[aesthetic]] %||% center
#> }
#> <bytecode: 0x564062928760>
#> <environment: 0x564062927d18>

# Align all time points to the start of their granularity
aes_nudge(center = 0, left = 0, right = 0)
#> function (aesthetic) 
#> {
#>     offsets[[aesthetic]] %||% center
#> }
#> <bytecode: 0x564062928760>
#> <environment: 0x56406297d970>