Skip to contents

This function overlays the Region of Interest (ROI) on an existing melatonin profile plot. It adds a horizontal segment to mark the ROI range and optionally a shaded rectangle to highlight the full area that is parsed during the DLMO search.

Usage

plot_roi(plot, roi, roi_line_only)

Arguments

plot

A ggplot object. The base plot to which the ROI should be added.

roi

A list containing the Region of Interest (ROI) coordinates:

  • x_start (POSIXct) – The starting time of the ROI.

  • x_end (POSIXct) – The ending time of the ROI.

  • y_min (numeric) – The minimum melatonin concentration in the ROI.

  • y_max (numeric) – The maximum melatonin concentration in the ROI.

roi_line_only

Logical. If TRUE, only the horizontal segment is plotted. If FALSE, a semi-transparent rectangle is added to indicate the full ROI region.

Value

A ggplot object with the ROI overlay.

Details

  • The horizontal segment is plotted at y = -0.2 to clearly mark the time range of the ROI.

  • If roi_line_only = FALSE, the rectangle spans from y_min to y_max with a light orchid3 fill.

Examples

if (FALSE) { # \dontrun{
  plot <- ggplot2::ggplot(profile_data, ggplot2::aes(x = datetime, y = melatonin)) +
      ggplot2::geom_point()
  roi <- list(x_start = as.POSIXct("2024-04-16 18:00:00"),
              x_end = as.POSIXct("2024-04-16 22:00:00"),
              y_min = 0.2, y_max = 2.5)
  plot_roi(plot, roi, roi_line_only = FALSE)
} # }