Use an age depth model as a second ggplot axis

age_depth_as_sec_axis(x, primary = c("depth", "age"), ...)

Arguments

x

An age_depth_model

primary

Specify the primary axis as 'age' or 'depth'

...

Passed to sec_axis

Value

A ggplot2 sec_axis for use in scale_x_continuous, scale_y_continuous, or their reverse variants.

Examples

library(ggplot2)
alta_lake_adm <- age_depth_model(
  alta_lake_210Pb_ages,
  depth = depth_cm,
  age = age_year_ad
)

ggplot(alta_lake_210Pb_ages, aes(y = depth_cm, x = age_year_ad)) +
  geom_path() +
  geom_point() +
  scale_y_reverse(sec.axis = age_depth_as_sec_axis(alta_lake_adm))