Skip to content

Plot customizations for censored VPC#69

Merged
certara-jcraig merged 1 commit intomasterfrom
PMXRD-220-blq-alq-plot-customizations
Jan 27, 2026
Merged

Plot customizations for censored VPC#69
certara-jcraig merged 1 commit intomasterfrom
PMXRD-220-blq-alq-plot-customizations

Conversation

@certara-jcraig
Copy link
Collaborator

Adds the ability to customize colors in censoring (BLQ/ALQ) plots through new censoring.color and censoring.fill arguments in plot.tidyvpcobj(), addressing the feature request #67 to allow easier changing of BLQ/ALQ colour labels.

  • Added censoring.color argument (named vector for line colors, default: c(observed = "black", simulated = "red"))
  • Added censoring.fill argument (ribbon fill color, default: "red")
  • Updated plot_censored() internal function to use these parameters instead of hardcoded values
  • Updated /vignettes/tidyvpc_cont.Rmd adding "Customizing Censoring Plot Colors" subsection with examples

Usage examples

Basic color customization via new arguments

library(tidyvpc)

vpc <- observed(obs_data, x = TIME, y = DV) %>%
  simulated(sim_data, y = DV) %>%
  censoring(blq = DV < 50, lloq = 50) %>%
  binning(bin = "jenks", nbins = 5) %>%
  vpcstats()

# Customize censoring plot colors directly
plot(vpc, censoring.type = "blq",
     censoring.color = c(observed = "blue", simulated = "orange"),
     censoring.fill = "orange")

For users who need full ggplot2 control, use censoring.output = "list" to return individual ggplot objects that can be modified:

# Get plots as a list instead of arranged grid
plot_list <- plot(vpc, censoring.type = "blq", censoring.output = "list")

# plot_list[[1]] = main VPC plot
# plot_list[[2]] = BLQ percentage plot

# Customize the BLQ plot with ggplot2 functions
plot_list[[2]] + 

  ggplot2::scale_colour_manual(
    values = c(observed = "darkgreen", simulated = "purple")
  ) +
  ggplot2::labs(
    colour = "Custom Legend Title",
    title = "Percentage Below Limit of Quantification"
  ) +
  ggplot2::theme_minimal()

# Combine plots manually using patchwork or cowplot
library(patchwork)
plot_list[[1]] / plot_list[[2]]

@certara-jcraig certara-jcraig merged commit 1aeb393 into master Jan 27, 2026
4 checks passed
@certara-jcraig certara-jcraig deleted the PMXRD-220-blq-alq-plot-customizations branch January 27, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant