Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions R/plotTimeProfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ plotTimeProfile <- function(data = NULL, # nolint
geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"),
geomLLOQAttributes = getDefaultGeomAttributes("LLOQ"),
groupAesthetics = c("colour", "fill", "shape")) {

Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary blank line added at the beginning of the function body. This adds no value and should be removed to maintain clean code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
groupAesthetics <- ggplot2::standardise_aes_names(groupAesthetics)
.validatePlotTimeProfileInputs(
data = data,
Expand Down Expand Up @@ -185,7 +186,7 @@ plotTimeProfile <- function(data = NULL, # nolint
is.null(listMappedData$mapSimulatedAndObserved) &&
all(c("colour", "shape") %in% groupAesthetics)) {
plotObject <- plotObject +
scale_shape(guide = "none")
guides(shape = "none")
}

return(plotObject)
Expand Down Expand Up @@ -375,7 +376,7 @@ plotTimeProfile <- function(data = NULL, # nolint
#' @param commonLimits common limits for simulated and observed data
#' @param y2ScaleArgs list with arguments for secondary y-axis
#' @param requireDualAxis boolean if TRUE secondary axis is needed
#' @param yScaleArgs list with y2scale arguments
#' @param yScaleArgs list with yScale arguments
#'
#' @return list with
#' `simMappedData` adjusted object of class `MappedDataTimeprofile` for simulated data
Expand Down Expand Up @@ -541,7 +542,7 @@ plotTimeProfile <- function(data = NULL, # nolint
plotObject <- plotObject +
scale_discrete_manual(aesthetic,
values = mapSimulatedAndObserved[[aesthetic]],
guide = guide_legend(order = 1, title = "Simulated")
guide = guide_legend(order = 2, title = "Simulated")
)
}
}
Expand Down Expand Up @@ -573,8 +574,12 @@ plotTimeProfile <- function(data = NULL, # nolint
# to separate simulated and observed legend entries and start again with default colors
if (!is.null(mapSimulatedAndObserved)) {
for (aesthetic in groupAesthetics) {
guidesList <- stats::setNames(
list(guide_legend(title = "Simulated", order = 2)),
aesthetic
)
plotObject <- plotObject +
guides(aesthetic = guide_legend(title = "observed", order = 1)) +
guides(!!!guidesList) +
Comment on lines +577 to +582
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block creates a single-element list for one aesthetic inside a loop over multiple groupAesthetics. This approach differs from the similar code at lines 191-200 which correctly uses lapply to create guides for all aesthetics at once. Consider refactoring to match that pattern for consistency and to avoid repeatedly calling guides() inside the loop.

Copilot uses AI. Check for mistakes.
ggnewscale::new_scale(new_aes = aesthetic)
Comment on lines +577 to 583
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code creates a guides list for simulated data when it should be creating one for observed data. The title says 'Simulated' but this section is meant to set up the observed data legend before adding new scale. The title should be 'Observed' and the order should be 1, not 2.

Copilot uses AI. Check for mistakes.
}
}
Expand Down
Loading
Loading