Skip to content

Add chain_color option to graph.curve.params() for customizing MCMC line color#455

Merged
Kwan-Jenny merged 23 commits into
mainfrom
update_graph_curve2
Jul 18, 2025
Merged

Add chain_color option to graph.curve.params() for customizing MCMC line color#455
Kwan-Jenny merged 23 commits into
mainfrom
update_graph_curve2

Conversation

@Kwan-Jenny

Copy link
Copy Markdown
Contributor

This PR introduces a new chain_color argument to the graph.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:

  • New feature: chain_color argument added to graph.curve.params().
  • Default behavior retains color-coding by chain; setting chain_color = FALSE makes all MCMC lines black.
  • Examples updated in inst/examples/exm-graph.curve.params.R to demonstrate:
  • Default behavior
  • Custom quantiles
  • Use of chain_color = FALSE
  • Tests updated in tests/testthat/test-graph.curve.params.R:
    • Visual regression tests using vdiffr::expect_doppelganger()
    • Includes plots with default settings, custom quantiles, and black chain coloring
    • Also tests log_x = TRUE option for coverage

This update enhances visual flexibility and clarity for plotting antibody decay models, especially in publication-quality figures with many MCMC samples.

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

codecov Bot commented Jul 8, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
R/graph.curve.params.R 97.20% <100.00%> (+0.05%) ⬆️

@github-actions

github-actions Bot commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

📕 Preview documentation for this PR has been cleaned up.

Kwan-Jenny and others added 8 commits July 8, 2025 16:56
# 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.
@Kwan-Jenny Kwan-Jenny requested a review from d-morrison July 16, 2025 21:52

@d-morrison d-morrison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! a few notes

Comment thread R/graph.curve.params.R Outdated
Comment thread tests/testthat/test-graph.curve.params.R Outdated
Comment thread R/graph.curve.params.R Outdated
Comment thread R/graph.curve.params.R Outdated
Kwan-Jenny and others added 7 commits July 17, 2025 10:52
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 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.
@Kwan-Jenny Kwan-Jenny requested a review from d-morrison July 17, 2025 20:01

@d-morrison d-morrison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

almost there! two more comments

Comment thread R/graph.curve.params.R Outdated
Comment thread tests/testthat/test-graph.curve.params.R Outdated
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 d-morrison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! This PR looks great to me - short and sweet!

@Kwan-Jenny Kwan-Jenny merged commit 0f7a05a into main Jul 18, 2025
17 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.

2 participants