From 48a3dd5c892f214caaf8609a5c5afd7408131c09 Mon Sep 17 00:00:00 2001
From: certara-jcraig <61294078+certara-jcraig@users.noreply.github.com>
Date: Tue, 5 Sep 2023 16:57:07 -0700
Subject: [PATCH 1/3] ensure x axis for blq/alq plot is same scale as vpc plot
---
R/plot.R | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/R/plot.R b/R/plot.R
index 9ab30dd..13682cb 100644
--- a/R/plot.R
+++ b/R/plot.R
@@ -136,12 +136,30 @@ plot.tidyvpcobj <- function(x,
if (censoring.type %in% c("both", "blq")) {
g_blq <-
- plot_censored(vpc, type = "blq", facet.scales, custom.theme, legend.position)
+ plot_censored(
+ vpc,
+ type = "blq",
+ facet.scales,
+ custom.theme,
+ legend.position,
+ show.points,
+ show.boundaries,
+ show.binning
+ )
}
if (censoring.type %in% c("both", "alq")) {
g_alq <-
- plot_censored(vpc, type = "alq", facet.scales, custom.theme, legend.position)
+ plot_censored(
+ vpc,
+ type = "alq",
+ facet.scales,
+ custom.theme,
+ legend.position,
+ show.points,
+ show.boundaries,
+ show.binning
+ )
}
grid_list <-
@@ -450,12 +468,16 @@ plot_censored <-
facet.scales = c("free", "fixed"),
custom.theme,
legend.position,
- ...) {
+ show.points,
+ show.boundaries,
+ show.binning) {
stopifnot(inherits(vpc, "tidyvpcobj"))
hi <- lo <- md <- xbin <- y <- NULL
+ . <- list
method <- vpc$vpc.method$method
+
if(method == "binning") {
xvar <- "xbin"
} else {
@@ -503,6 +525,25 @@ plot_censored <-
) +
labs(x = "TIME", y = paste0("% ", toupper(type)))
+ # ensure x axis is same scale given options in vpc plot that can affect xmax
+ if (method == "binning" &&
+ any(show.binning, show.boundaries, show.points)) {
+ if (any(show.binning, show.boundaries)) {
+ xlim_df <-
+ bininfo(vpc)[, .(x = sort(unique(c(xleft, xright)))), by = names(vpc$strat)]
+ } else {
+ xlim_df <-
+ copy(vpc$obs)[!(blq |
+ alq)][, .(x = max(x)), by = names(vpc$strat)]
+ }
+ g <- g + ggplot2::geom_rug(
+ data = xlim_df,
+ ggplot2::aes(x = x),
+ sides = "t",
+ alpha = 0
+ )
+ }
+
# add theme
if (is.null(custom.theme)) {
g <- g + ggplot2::theme_bw() + tidyvpc_theme(legend.position = legend.position)
From e4e66934d7b43db8731e5ab96fed51a8b069c9d5 Mon Sep 17 00:00:00 2001
From: certara-jcraig <61294078+certara-jcraig@users.noreply.github.com>
Date: Tue, 5 Sep 2023 16:57:46 -0700
Subject: [PATCH 2/3] update tests for new censoring xaxis scale
---
.../_snaps/plot/censored-plot-with-aql.svg | 228 +++++----
.../plot/censored-plot-with-bql-aql.svg | 456 ++++++++++--------
.../_snaps/plot/censored-plot-with-bql.svg | 228 +++++----
3 files changed, 488 insertions(+), 424 deletions(-)
diff --git a/tests/testthat/_snaps/plot/censored-plot-with-aql.svg b/tests/testthat/_snaps/plot/censored-plot-with-aql.svg
index 3c3c60b..a358ba8 100644
--- a/tests/testthat/_snaps/plot/censored-plot-with-aql.svg
+++ b/tests/testthat/_snaps/plot/censored-plot-with-aql.svg
@@ -765,26 +765,34 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -799,24 +807,32 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -894,32 +910,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
@@ -1672,26 +1680,34 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1701,24 +1717,32 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1781,32 +1805,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
diff --git a/tests/testthat/_snaps/plot/censored-plot-with-bql-aql.svg b/tests/testthat/_snaps/plot/censored-plot-with-bql-aql.svg
index 75e8e94..5a23a25 100644
--- a/tests/testthat/_snaps/plot/censored-plot-with-bql-aql.svg
+++ b/tests/testthat/_snaps/plot/censored-plot-with-bql-aql.svg
@@ -896,27 +896,35 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -931,25 +939,33 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -989,26 +1005,34 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1023,24 +1047,32 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1118,32 +1150,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
@@ -1170,32 +1194,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
@@ -2083,27 +2099,35 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2113,25 +2137,33 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2161,26 +2193,34 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2190,24 +2230,32 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2270,32 +2318,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
@@ -2317,32 +2357,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
diff --git a/tests/testthat/_snaps/plot/censored-plot-with-bql.svg b/tests/testthat/_snaps/plot/censored-plot-with-bql.svg
index e6d9fb5..8a2db2d 100644
--- a/tests/testthat/_snaps/plot/censored-plot-with-bql.svg
+++ b/tests/testthat/_snaps/plot/censored-plot-with-bql.svg
@@ -768,27 +768,35 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -803,25 +811,33 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -901,32 +917,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
@@ -1682,27 +1690,35 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1712,25 +1728,33 @@
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1795,32 +1819,24 @@
-
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
-12.5
+
+
+
+
+0
+5
+10
+15
-
-
-
-
-
-0.0
-2.5
-5.0
-7.5
-10.0
+
+
+
+0
+5
+10
From 89f5fe873ab482bc634caad92fa45cc6037618a8 Mon Sep 17 00:00:00 2001
From: certara-jcraig <61294078+certara-jcraig@users.noreply.github.com>
Date: Tue, 5 Sep 2023 17:19:26 -0700
Subject: [PATCH 3/3] data.table by arg cannot be NULL
---
R/plot.R | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/R/plot.R b/R/plot.R
index 13682cb..84667ef 100644
--- a/R/plot.R
+++ b/R/plot.R
@@ -529,12 +529,23 @@ plot_censored <-
if (method == "binning" &&
any(show.binning, show.boundaries, show.points)) {
if (any(show.binning, show.boundaries)) {
- xlim_df <-
- bininfo(vpc)[, .(x = sort(unique(c(xleft, xright)))), by = names(vpc$strat)]
+ if (!is.null(vpc$strat)) {
+ xlim_df <-
+ bininfo(vpc)[, .(x = sort(unique(c(xleft, xright)))), by = names(vpc$strat)]
+ } else {
+ xlim_df <-
+ bininfo(vpc)[, .(x = sort(unique(c(xleft, xright))))]
+ }
} else {
- xlim_df <-
- copy(vpc$obs)[!(blq |
- alq)][, .(x = max(x)), by = names(vpc$strat)]
+ if (!is.null(vpc$strat)) {
+ xlim_df <-
+ copy(vpc$obs)[!(blq |
+ alq)][, .(x = max(x)), by = names(vpc$strat)]
+ } else {
+ xlim_df <-
+ copy(vpc$obs)[!(blq |
+ alq)][, .(x = max(x))]
+ }
}
g <- g + ggplot2::geom_rug(
data = xlim_df,