This function adds a parallelogram visualization to a melatonin profile plot. The best-fit parallelogram encompasses all ascending points with the smallest area parallelogram possible. The ratio of parallelogram latera edge to long diagonal is used as a criterion for trimming the ascending region to ensure that only a sufficiently fast enough melatonin rise is taken into consideration when fitting the profile and searching for the DLMO point.
Arguments
- plot
A ggplot object. The base plot to which the parallelogram will be added.
- profile_data
A dataframe containing melatonin concentration data with
datetimevalues.- pll_result
A list containing the optimized parallelogram parameters, including:
pll_datetime_0: POSIXct timestamp for the left boundary.pll_datetime_1: POSIXct timestamp for the right boundary.pll_slope: Numeric. The slope of the parallelogram's edges.corners: A list of four corner coordinates (ll,lr,ur,ul).
Details
The parallelogram is generated using the optimized fit from
parallelogram_fit().The edges of the parallelogram indicate a bounded region of interest (ROI).
Two diagonal dashed lines highlight the shape constraints used during optimization.
Uses red fill with transparency (alpha = 0.1) to avoid obscuring data.
Examples
if (FALSE) { # \dontrun{
plot <- ggplot2::ggplot(profile_data, ggplot2::aes(x = datetime, y = melatonin)) +
ggplot2::geom_point()
plot <- plot_parallelogram(plot, profile_data, pll_result)
} # }