Skip to content

Commit

Permalink
Plot order (#784)
Browse files Browse the repository at this point in the history
* preserve order of distributions when plotting

* update news item

* add PR number and reviewer

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>

---------

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>
  • Loading branch information
sbfnk and jamesmbaazam authored Sep 20, 2024
1 parent 998b0e5 commit 854b23e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- a bug was fixed that caused delay option functions to report an error if only the CDF cutoff was specified. By @sbfnk.
- a bug was fixed that led to the truncation PMF being shortened from the wrong side when the truncation PMF was longer than the supplied data. By @seabbs in #736 and reviewed by @sbfnk and @jamesmbaazam.
- a bug was fixed that caused internal validation checks on delay distributions to fail if they contained non-parametric distributions. By @jamesmbaazam in #750 and reviewed by @seabbs.
- a bug was fixed where combined distributions where shown in alphabetical order, rather than the order in which they were combined. By @sbfnk in #784 and reviewed by @jamesmbaazam.

## Documentation

Expand Down
7 changes: 4 additions & 3 deletions R/dist_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,10 @@ plot.dist_spec <- function(x, samples = 50L, res = 1, cumulative = TRUE, ...) {
}
return(pmf_dt)
})
pmf_data <- rbindlist(pmf_data)[,
type := factor("pmf", levels = c("pmf", "cmf"))
]
pmf_data <- rbindlist(pmf_data)[, `:=`(
type = factor("pmf", levels = c("pmf", "cmf")),
distribution = factor(distribution, levels = unique(distribution))
)]

# Plot PMF and CDF as facets in the same plot
plot <- ggplot(
Expand Down

0 comments on commit 854b23e

Please sign in to comment.