Skip to content

plot.psa(center = FALSE): no fill-scale warning - #247

Merged
feralaes merged 2 commits into
mainfrom
fix-plot-psa-fill-warning
Nov 13, 2026
Merged

feralaes merged 2 commits into
mainfrom
fix-plot-psa-fill-warning

Conversation

@feralaes

Copy link
Copy Markdown
Collaborator

What

plot(psa, center = FALSE) warned when the plot was drawn:

No shared levels found between names(values) of the manual scale and the data's fill values.

Only the center points use the fill aesthetic, but plot.psa() always asked add_common_aes() for a fill scale. Without center points the scale had nothing to match. This affected both the cost-effectiveness plane and the incremental plane (ref_str). The default plot (center = TRUE) was never affected.

Change

Both branches of plot.psa() now pass col_aes = c("color", "fill") only when center = TRUE, and "color" otherwise.

Tests

New test in test_plot_options.R: ggplot_build() raises no warning with center = FALSE, ellipse = FALSE, on both planes and for every col option. With center points, the plot still has both color and fill scales. The test fails 6 times without the fix.

Verification

  • devtools::test(): 345 passed, 0 failed. The remaining 3 warnings are mgcv's "k has been set to its minimum" in test_metamod.R, unrelated.
  • lintr::lint_package(): 0 lints.
  • All vignette and Rd example outputs are identical to main.
  • R CMD check --as-cran: only the development-version NOTE.
  • NEWS entry under Bug fixes.

Found while fixing CI on #227. It is independent of #227 and can merge in either order.

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).
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.09%. Comparing base (a9f7d86) to head (6277fe6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #247   +/-   ##
=======================================
  Coverage   93.08%   93.09%           
=======================================
  Files          18       18           
  Lines        1822     1824    +2     
=======================================
+ Hits         1696     1698    +2     
  Misses        126      126           
Files with missing lines Coverage Δ
R/psa.R 94.03% <100.00%> (+0.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@feralaes
feralaes merged commit a018d81 into main Nov 13, 2026
12 checks passed
@feralaes
feralaes deleted the fix-plot-psa-fill-warning branch November 13, 2026 23:57
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