You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do we want to add a (S3 method) plotting function for the output from scenario_sim() to enable users to easily plot results?
I think it would be good to provide a plotting function with useful defaults and labels which outputs a ggplot object for the user to easily edit.
I'd be interested to hear thoughts on if a plot() method would be useful, if so whether we should use {ggplot2}, base R or another plotting framework (considerations of dependencies), and if there are any learnings from similar packages that provide a plot() method (e.g. {EpiNow2}).
I'm generally skeptical of pulling in more dependencies, but I do think it's useful to provide users a standard-ish way to have this sort of capability.
Could be done with vignette snippet? Maybe something in inst? Also possible with an extension package, but that's a bit unwieldy for both users and dev.
I think vignette is best - would also show the interior code where people might want a specialized tweak.
This is partially (or potentially fully) addressed by the changes in PR #201 which adds plotting code chunks. The vignette uses {tinyplot} which is a dependency-free (only depends on packages that are shipped with R, e.g. {grDevices}) package and has a nice user-interface.
If the main concern for providing a plotting method for scenario_sim() is the extra dependencies {ggplot2} would pull in, then {tinyplot} could be a good alternative. The downside is that it does not allow users to edit with layers in the same (and familiar) way.
I think the vignette snippet provides a sufficient minimal solution. Would be nice to add a ggplot2 chunk in approximately the same place (for people who prefer minimal dependencies vs the common demand for nice extras).
Also worth revising the scenario_sim() docs to point to the vignettes as a place where people can grab standard-ish, reusable plotting code.
Would be nice to add a ggplot2 chunk in approximately the same place (for people who prefer minimal dependencies vs the common demand for nice extras).
Okay, my proposed solution is: keep the current vignettes with only {tinyplot} for the CRAN/default version, and then use pkgdown::in_pkgdown() to determine when the vignettes are being rendered for the website and add a tabset with a tab containing the equivalent plotting code with {ggplot2}.
The reason for this is that it would avoid adding {ggplot2} to Imports or Suggests and can instead be added to Config/Needs in the DESCRIPTION file or directly into pkgdown.yamlr-lib/actions/setup-r-dependencies@v2. On the other hand {ggplot2} would only need to go into Suggests, so it wouldn't be tightly coupled, but I feel that the suggested dependencies are often installed (e.g. during CI runs) so keeping it only for the website keeps things more lightweight.
Also IIRC the tabsetting doesn't render on CRAN vignettes.
Looking to close this issue. My preferred solution to this issue is to create a companion package (e.g. {VisRingbp} or {ringbp.plot}). Mainly because {ringbp} is used in {propose} which contains plotting code, so it's probably good to have that plotting code separated out, documented, tested and usable by others, independent of {propose}.
reasonable suggestion; even if you do decide to show some plotting in vignettes, makes that work still easier if there's another package that just does good pre-sets.
Activity
pearsonca commentedon Sep 15, 2025
I'm generally skeptical of pulling in more dependencies, but I do think it's useful to provide users a standard-ish way to have this sort of capability.
Could be done with vignette snippet? Maybe something in inst? Also possible with an extension package, but that's a bit unwieldy for both users and dev.
I think vignette is best - would also show the interior code where people might want a specialized tweak.
joshwlambert commentedon Jan 26, 2026
This is partially (or potentially fully) addressed by the changes in PR #201 which adds plotting code chunks. The vignette uses {tinyplot} which is a dependency-free (only depends on packages that are shipped with R, e.g. {grDevices}) package and has a nice user-interface.
If the main concern for providing a plotting method for
scenario_sim()is the extra dependencies {ggplot2} would pull in, then {tinyplot} could be a good alternative. The downside is that it does not allow users to edit with layers in the same (and familiar) way.pearsonca commentedon Jan 26, 2026
I think the vignette snippet provides a sufficient minimal solution. Would be nice to add a ggplot2 chunk in approximately the same place (for people who prefer minimal dependencies vs the common demand for nice extras).
Also worth revising the scenario_sim() docs to point to the vignettes as a place where people can grab standard-ish, reusable plotting code.
joshwlambert commentedon Jan 27, 2026
Okay, my proposed solution is: keep the current vignettes with only {tinyplot} for the CRAN/default version, and then use
pkgdown::in_pkgdown()to determine when the vignettes are being rendered for the website and add a tabset with a tab containing the equivalent plotting code with {ggplot2}.The reason for this is that it would avoid adding {ggplot2} to
ImportsorSuggestsand can instead be added toConfig/Needsin theDESCRIPTIONfile or directly intopkgdown.yamlr-lib/actions/setup-r-dependencies@v2. On the other hand {ggplot2} would only need to go intoSuggests, so it wouldn't be tightly coupled, but I feel that the suggested dependencies are often installed (e.g. during CI runs) so keeping it only for the website keeps things more lightweight.Also IIRC the tabsetting doesn't render on CRAN vignettes.
joshwlambert commentedon Jun 15, 2026
Looking to close this issue. My preferred solution to this issue is to create a companion package (e.g. {VisRingbp} or {ringbp.plot}). Mainly because {ringbp} is used in {propose} which contains plotting code, so it's probably good to have that plotting code separated out, documented, tested and usable by others, independent of {propose}.
pearsonca commentedon Jun 15, 2026
reasonable suggestion; even if you do decide to show some plotting in vignettes, makes that work still easier if there's another package that just does good pre-sets.