Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve <epidist> plotting method #315

Merged
merged 17 commits into from
May 24, 2024
Merged

Improve <epidist> plotting method #315

merged 17 commits into from
May 24, 2024

Conversation

joshwlambert
Copy link
Member

@joshwlambert joshwlambert commented May 24, 2024

This PR improves the S3 plotting method for the <epidist> class (plot.epidist()). The plotting function now plots a single distribution instead of a grid of two distributions. It plots the PDF/PMF by default, and can plot the cumulative distribution when cumulative = TRUE.

The updates mean there is a more noticable difference between plotting continuous versus discrete (or discretised) distributions. Before both would be plotted as dotted lines, now, the continuous distributions are plotted as curves, and the discrete (and discretised) distributions are plotted as bar graphs.

The <vb_epidist> plotting method (plot.vb_epidist()) has been removed from the package in this PR as it was causing extra complication for the plot.epidist() function and did not have any usage in the package (or from any users that we are aware of). This has the benefit that the vb and title arguments in plot.epidist() have been removed, simplifying the function signature.

The day_range argument has also been removed from plot.epidist() in favour of using the more idiomatic xlim argument from the plot.default() method (accessed via ... in plot.epidist()). This will hopefully be familiar users that have used base R plotting.

In the process issues #229 and #309 have been resolved.

A new function, is_continuous() has been added to the package to easily check whether an <epidist> object contains a continuous distribution. This is called in plot.epidist() to determine if the PDF or PMF should be plotted.

The function documentation and vignettes have been updated where necessary and unit tests and snapshots have been updated.

This PR supersedes PR #235 which implemented improvements to the <epidist> plotting using {ggplot2}, {ggdist} and {gridExtra}. I will close PR #235 in favour of this PR, but will leave the plot_method branch open for a few more months in case we decide to work on it or incorporate some features in the future.

@joshwlambert joshwlambert merged commit 20d55f9 into main May 24, 2024
10 checks passed
@joshwlambert joshwlambert deleted the improve_epidist_plot branch May 24, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants