Add chain_color option to graph.curve.params() for customizing MCMC line color#455
Merged
Conversation
Merge branch 'main' into update_graph_curve2 # Conflicts: # R/graph.curve.params.R # man/graph.curve.params.Rd # tests/testthat/_snaps/graph.curve.params/curve-samples.svg # tests/testthat/test-graph.curve.params.R
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found.
|
Contributor
|
📕 Preview documentation for this PR has been cleaned up. |
# Conditionally sets the legend title in `graph.curve.params()` to accurately reflect the plot contents. - Displays "MCMC chain" when colored chains and quantiles are shown. - Hides the title when black chains and quantiles are shown to avoid confusion. - Displays "Quantile" when only quantile lines are plotted.
d-morrison
requested changes
Jul 17, 2025
Co-authored-by: Douglas Ezra Morrison <demorrison@ucdavis.edu>
This commit refactors the graph.curve.params function for clarity and improved output. The if/else block for adding geom_line layers has been streamlined by dynamically building a parameter list. This makes the code more concise and easier to maintain. Additionally, the legend title 'Quantile' has been removed when only quantile lines are plotted, resulting in a cleaner visualization.
This commit adds more descriptive comments to the tests for graph.curve.params to clarify the purpose of each test case. This makes it clear why certain parameters are used, for example, to specifically test the disabling of quantile lines.
This reverts commit bccf311.
This commit refactors the plotting logic for MCMC samples by consolidating the if/else block into a single geom_line call. A conditional is now used inside the aes() mapping to dynamically handle the color aesthetic, making the code more concise and removing duplication.
This reverts commit 760a6c5.
d-morrison
requested changes
Jul 17, 2025
d-morrison
left a comment
Member
There was a problem hiding this comment.
almost there! two more comments
This commit refactors the nested if-else block for setting the legend label. The logic is now consolidated into a single conditional expression to determine the label text, which is then applied in one step. This improves readability and maintainability by removing duplicated code.
d-morrison
approved these changes
Jul 18, 2025
d-morrison
left a comment
Member
There was a problem hiding this comment.
Thanks! This PR looks great to me - short and sweet!
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.
This PR introduces a new
chain_colorargument to thegraph.curve.params()function, allowing users to control whether MCMC sample lines are colored by chain (default) or plotted in black (chain_color = FALSE).Summary of changes:
chain_colorargument added tograph.curve.params().chain_color = FALSEmakes all MCMC lines black.inst/examples/exm-graph.curve.params.Rto demonstrate:chain_color = FALSEtests/testthat/test-graph.curve.params.R:vdiffr::expect_doppelganger()log_x = TRUEoption for coverageThis update enhances visual flexibility and clarity for plotting antibody decay models, especially in publication-quality figures with many MCMC samples.