Skip to contents

This function adds a DLMO inflection point as a distinct marker to an existing melatonin profile plot. The inflection point is represented by a filled deep pink square.

Usage

plot_ip(plot, profile_data, dlmoip, datetime_ref = NULL)

Arguments

plot

A ggplot object. The base plot of the melatonin profile.

profile_data

A dataframe containing melatonin concentration data, with required columns:

  • datetime (POSIXct) – Time of measurement.

dlmoip

A list containing the estimated inflection point coordinates:

  • x (numeric) – The estimated inflection point time (in decimal hours).

  • y (numeric) – The estimated melatonin concentration at the inflection point.

Value

A ggplot object with the inflection point added.

Details

  • The inflection point represents the DLMO time stamp, at which melatonin concentration begins to rise significantly.

  • The function converts the inflection point x from decimal hours back to POSIXct for proper placement.

  • The point is styled as a deep pink filled square.

Examples

if (FALSE) { # \dontrun{
  plot <- ggplot2::ggplot(profile_data, ggplot2::aes(x = datetime, y = melatonin)) +
      ggplot2::geom_point()
  dlmoip <- list(x = 20.5, y = 3.2)  # Inflection point at 20.5 decimal hours, y = 3.2 pg/mL
  plot_ip(plot, profile_data, dlmoip)
} # }