Skip to content

Replace c(mult, add) with expansion() in scale expand args#485

Merged
jgabry merged 4 commits intostan-dev:masterfrom
utkarshpawade:fix/use-expansion-helper-in-scale-expand
Mar 16, 2026
Merged

Replace c(mult, add) with expansion() in scale expand args#485
jgabry merged 4 commits intostan-dev:masterfrom
utkarshpawade:fix/use-expansion-helper-in-scale-expand

Conversation

@utkarshpawade
Copy link
Contributor

Fixes #484

Summary
•Replaced all old-style expand = c(mult, add) numeric vector arguments with the expansion() helper across helpers-gg.R, mcmc-•diagnostics.R, mcmc-diagnostics-nuts.R, mcmc-distributions.R, and mcmc-parcoord.R
•The expansion() helper was introduced in ggplot2 3.3.0 and is the documented modern approach; the old c(mult, add) format is still supported but discouraged
•Brings these files in line with the style already used in mcmc-intervals.R and ppc-loo.R.

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.66%. Comparing base (b98d1e3) to head (bf8996e).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #485      +/-   ##
==========================================
- Coverage   98.70%   98.66%   -0.04%     
==========================================
  Files          35       35              
  Lines        5857     5857              
==========================================
- Hits         5781     5779       -2     
- Misses         76       78       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup looks only partial to me. The direct scale_*() calls were updated to expansion(), but there are still calls to helper functions using the old numeric c(mult, add) form. Since dont_expand_y_axis() just forwards expand into scale_y_continuous(), the old-style expand is still being used indirectly.

facet_wrap(..., labeller = label_parsed)
}
dont_expand_y_axis <- function(expand = c(0,0)) {
dont_expand_y_axis <- function(expand = expansion(0, 0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default here is good, but there are still places in the code where we call e.g.

dont_expand_y_axis(c(0.005, 0))

in which case this is still using the old behavior.

Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added a few regression tests to check the panel expansion. If everything passes we can merge.

@jgabry jgabry merged commit a30a706 into stan-dev:master Mar 16, 2026
6 checks passed
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.

Standardize scale expand arguments to use expansion() helper instead of c(mult, add)

3 participants