plot_tdt_curve: Plot a posterior LT_x curve

View source: R/plotting.R

plot_tdt_curveR Documentation

Plot a posterior LT_x curve

Description

Plots posterior median +/- 95% CrI of the duration to reach target_surv across temperature. By default, returns a two-panel figure: a linear-time panel (the absolute time to reach the target) alongside a log10-time panel (the classical TDT view where the relationship is near-linear with slope -1/z). Both panels share posterior draws.

Usage

plot_tdt_curve(
  ltx,
  panels = c("both", "linear", "log"),
  colour = "#146C7C",
  observed = NULL,
  clip_to_observed = TRUE
)

Arguments

ltx

Output of derive_tdt_curve().

panels

One of "both" (default), "linear", or "log".

colour

Line/ribbon colour. Default "#146C7C".

observed

Optional standardised data tibble (from standardize_data()). Only used, together with clip_to_observed, to trim the temperature axis.

clip_to_observed

Logical. If TRUE (the default) and observed is supplied, each group's curve is drawn only over its observed assay-temperature range (the temperature grid is chosen by derive_tdt_curve(), so this only trims a grid drawn wider than the data). A no-op without observed.

Details

Grouped output from derive_tdt_curve() with by = ... is faceted automatically so each moderator level gets its own TDT curve panel.

Internal y-axis behaviour: if the 95% credible interval of the LT_x curve extends above 48 hours (converted to ltx$output_time_unit), both panels' y-axes are clamped to 48 hours so the readable part of the curve isn't compressed by an extreme upper tail at cool temperatures. If the data already stay below 48 hours, no limits are applied and ggplot2 chooses a data-driven range. To override it, append + ggplot2::coord_cartesian(ylim = ...) to a single-panel plot (panels = "linear" or "log"). For the two-panel default, use patchwork's & so the limits reach both panels, with a positive lower limit because one axis is logarithmic.

Value

A ggplot object (single panel) or patchwork composition (two panels).

Examples

## Not run: 
ltx <- derive_tdt_curve(wf, temp_grid = seq(29, 37, by = 0.5))
plot_tdt_curve(ltx)                  # two-panel default
plot_tdt_curve(ltx, panels = "log")  # classical TDT view only

# Override the internal 48-h cap on one panel by appending a coord_cartesian:
plot_tdt_curve(ltx, panels = "linear") +
  ggplot2::coord_cartesian(ylim = c(0, 240))
# ... or on both panels with patchwork's `&` (the log axis needs a lower
# limit above 0):
plot_tdt_curve(ltx) & ggplot2::coord_cartesian(ylim = c(1, 240))

## End(Not run)

bayesTLS documentation built on Nov. 29, 2026, 1:06 a.m.