Skip to content

fix: plot coverage as numeric in R plot_cross_validation_metric - #2783

Open
ZainnQureshii wants to merge 1 commit into
meta:mainfrom
ZainnQureshii:fix/plot-cv-metric-coverage-numeric
Open

ZainnQureshii wants to merge 1 commit into
meta:mainfrom
ZainnQureshii:fix/plot-cv-metric-coverage-numeric

Conversation

@ZainnQureshii

Copy link
Copy Markdown

Fixes #2721.

plot_cross_validation_metric(df_cv, 'coverage') plots the per-point coverage, which coverage() returns as logical, so with ggplot2 4.0 the y axis turns discrete: FALSE/TRUE land at 1 and 2 while the rolling average of 0.5 sits below them. This converts both plotted columns to numeric after performance_metrics() in R/R/plot.R, so the points sit at 0/1 on the same axis as the average. Both frames are converted because a negative rolling_window makes the average logical too. Numeric metrics are unchanged.

The new test in R/tests/testthat/test_diagnostics.R checks the y scale is continuous and both layers' values, for rolling_window = -1 and 1.

Tested with R 4.5.3, ggplot2 4.0.0, testthat 3.3.1:

  • Rscript testthat.R in R/tests: without the fix 371 passed, 5 failed; with it 376 passed, 0 failed.
  • rcmdcheck with CI's --no-manual --as-cran flags: 0 errors, 0 warnings, 2 notes (clock lookup, unused imports, neither in the changed files).
  • devtools::document() leaves man/ unchanged.

Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.

🤖 Generated with Claude Code

coverage() returns logical per-point values, which ggplot2 4.0 puts on a
discrete axis (FALSE/TRUE at 1/2) beside a numeric rolling average.
Convert both plotted columns to numeric.

Fixes meta#2721

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed label Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plot_cross_validation_metric() (R version) may be incompatible with ggplot2 version 4.0.0

1 participant