Infer annotation aesthetics from the active ggplot2 theme (#120)#451
Open
ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
Open
Infer annotation aesthetics from the active ggplot2 theme (#120)#451ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
Conversation
Reference lines (e.g. the vertical zero-line in mcmc_intervals, the rhat=1 line in mcmc_rhat) previously used hardcoded colors like "gray90" that don't adapt when users switch ggplot2 themes. Added an internal annotation_style() helper that reads the active theme's gridline color and linewidth. When gridlines are present, the reference line inherits their color at double the major gridline width. When gridlines are blank (bayesplot's default), it falls back to the previous gray90/0.5 defaults so existing plots are unchanged. Closes stan-dev#120
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #451 +/- ##
==========================================
- Coverage 98.63% 98.35% -0.29%
==========================================
Files 35 35
Lines 5860 5883 +23
==========================================
+ Hits 5780 5786 +6
- Misses 80 97 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #120.
Reference lines like the vertical zero-line in
mcmc_intervals()and the rhat=1 line inmcmc_rhat()had hardcoded colors ("gray90","gray") that didn't adapt when users switched ggplot2 themes. As @tjmahr pointed out in the issue, this makes them invisible or look wrong on themes liketheme_grey()or dark themes.Added an internal
annotation_style()helper that reads the active theme's gridline color and linewidth to derive sensible reference line aesthetics. When gridlines are blank (bayesplot's default theme), it falls back to the previousgray90/0.5defaults so existing plots look exactly the same.Updated the four internal call sites in
mcmc-intervals.R(3xvline_0) andmcmc-diagnostics.R(1xvline_at) to use the new helper.