From 6f583f34d45cc6b96a0c7fc117e229e8d6248cd9 Mon Sep 17 00:00:00 2001 From: Fernando Alarid-Escudero Date: Fri, 13 Nov 2026 15:48:13 -0800 Subject: [PATCH 1/2] plot.psa(center = FALSE): add the fill scale only with the center points Without center points the plot has no fill aesthetic, so the manual fill scale from add_common_aes() made ggplot2 warn when the plot was drawn. Applies to both the cost-effectiveness plane and the incremental plane (ref_str). --- R/psa.R | 8 ++++++-- tests/testthat/test_plot_options.R | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/R/psa.R b/R/psa.R index 5d9ab9b..56b114e 100644 --- a/R/psa.R +++ b/R/psa.R @@ -229,7 +229,9 @@ plot.psa <- function(x, # add common theme col <- match.arg(col) - add_common_aes(psa_plot, txtsize, col = col, col_aes = c("color", "fill"), + # only the center points use fill; a fill scale without them makes ggplot2 warn + add_common_aes(psa_plot, txtsize, col = col, + col_aes = if (center) c("color", "fill") else "color", continuous = c("x", "y"), n_x_ticks = n_x_ticks, n_y_ticks = n_y_ticks, xbreaks = xbreaks, ybreaks = ybreaks, @@ -320,7 +322,9 @@ plot.psa <- function(x, # add common theme col <- match.arg(col) - add_common_aes(psa_plot, txtsize, col = col, col_aes = c("color", "fill"), + # only the center points use fill; a fill scale without them makes ggplot2 warn + add_common_aes(psa_plot, txtsize, col = col, + col_aes = if (center) c("color", "fill") else "color", continuous = c("x", "y"), n_x_ticks = n_x_ticks, n_y_ticks = n_y_ticks, xbreaks = xbreaks, ybreaks = ybreaks, diff --git a/tests/testthat/test_plot_options.R b/tests/testthat/test_plot_options.R index d46c083..e639464 100644 --- a/tests/testthat/test_plot_options.R +++ b/tests/testthat/test_plot_options.R @@ -27,6 +27,19 @@ test_that("plot.psa(ref_str = ): reference axes and caption are optional", { expect_setequal(as.character(unique(ggplot2::layer_data(p2, 1)$group)), c("1", "2")) }) +test_that("plot.psa() without center points builds without a fill-scale warning", { + # both the plain and the incremental CE plane, in every color option + for (col in c("access", "full", "bw")) { + expect_no_warning(ggplot2::ggplot_build(plot(psa_big, center = FALSE, ellipse = FALSE, col = col))) + expect_no_warning(ggplot2::ggplot_build(plot(psa_big, ref_str = "Chemo", center = FALSE, + ellipse = FALSE, col = col))) + } + # with center points, strategies still get matching color and fill + p <- plot(psa_big) + v_aes <- unlist(lapply(p$scales$scales, function(s) s$aesthetics)) + expect_true(all(c("colour", "fill") %in% v_aes)) +}) + test_that("plot.ceac(): frontier, points, and min_prob", { df_ceac <- ceac(v_wtp, psa_big) expect_true("GeomPoint" %in% geoms(plot(df_ceac))) From 6277fe63975ef5ab2ffb9aa66fb383eb22313a77 Mon Sep 17 00:00:00 2001 From: Fernando Alarid-Escudero Date: Fri, 13 Nov 2026 15:48:24 -0800 Subject: [PATCH 2/2] NEWS: plot.psa(center = FALSE) fill-scale warning --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index bc0f60d..6fbd484 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,7 @@ ## Bug fixes +- `plot.psa(center = FALSE)` no longer warns "No shared levels found between `names(values)` of the manual scale and the data's fill values" when it is drawn. The fill scale is now added only when the center points that use it are. - `plot.owsa(col = "bw")` now draws each strategy with its own line type; all strategies used to share one line type and could not be told apart (#176). - `metamodel()` now names invalid parameters in its error message, including when called through `calc_evppi()` and `calc_evsi()` (#177). - `gen_psa_samp()` now accepts the documented `"value, weight"` parameterization for `"bootstrap"` distributions. It used to be dropped silently, which shifted the parameterization of every later parameter by one position. **Samples from calls with a bootstrap parameter before other parameters will differ, because they are now correct.** Unknown distributions or parameterizations, and `params`, `dists`, `parameterization_types`, and `dists_params` of different lengths, now give informative errors instead of being dropped silently (#175).