Skip to content

plot.exp_loss(): readable labels on the log-scale y axis - #256

Merged
feralaes merged 1 commit into
mainfrom
elc-log-breaks
Nov 14, 2026
Merged

feralaes merged 1 commit into
mainfrom
elc-log-breaks

Conversation

@feralaes

Copy link
Copy Markdown
Collaborator

Found while adding expected loss curves to the README (#254).

Problem

plot.exp_loss() draws the y axis on a log scale by default (log_y = TRUE), but it took its breaks from number_ticks(), which spaces them evenly (0, 20,000, 40,000, …). On a log axis those labels bunch up at the top: 100,000 and 120,000 overlap. The lower part of the axis has no labels at all, and that's where the optimal strategy usually sits at low thresholds. With cancer_psa_data, everything below 20,000 was unlabeled, although the frontier goes down to about 1,000.

Change

With log_y = TRUE and no ybreaks given, the breaks now come from scales::breaks_log(n_y_ticks), which gives 1,000, 3,000, 10,000, 30,000, 100,000 for that example. If ybreaks is given, it's used as is. The linear axis (log_y = FALSE) is unchanged.

Tests

A new test in test_elc.R checks three things:

  • the default plot has a labelled break in every order of magnitude the data cover;
  • user-supplied ybreaks are kept;
  • the linear axis still has evenly spaced breaks.

The test fails without the fix.

Verification

  • 348 tests pass, with 0 lints.
  • Every example and vignette output is identical to main. Only axis labels change.
  • R CMD check --as-cran gives only the development-version NOTE.
  • NEWS entry under Bug fixes.

Merge before #254, so the README's expected loss figure is rendered with the fix.

With log_y = TRUE (the default), the y breaks came from number_ticks(), which spaces
them evenly. On a log axis they bunched up at the top and left the lower curves
without labels. Use scales::breaks_log(n_y_ticks) unless ybreaks is given.
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.15%. Comparing base (abee512) to head (7ba5d62).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
+ Coverage   93.09%   93.15%   +0.06%     
==========================================
  Files          18       18              
  Lines        1824     1826       +2     
==========================================
+ Hits         1698     1701       +3     
+ Misses        126      125       -1     
Files with missing lines Coverage Δ
R/exp_loss.R 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@feralaes
feralaes merged commit 6f745b6 into main Nov 14, 2026
13 checks passed
@feralaes
feralaes deleted the elc-log-breaks branch November 14, 2026 03:27
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