Skip to content

Commit

Permalink
Merge branch 'main' into unwpp
Browse files Browse the repository at this point in the history
  • Loading branch information
tinigarske committed Jan 10, 2025
2 parents 61bb2d1 + 82d8950 commit 98fdddb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
34 changes: 31 additions & 3 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
##' The colour in each cell corresponds to:
##' * for `plot_immunity()`: the proportion of each cohort that is
##' immune, therefore varying between 0 and 1.
##' * for `plot_pop_size()`: the size of each cohort.
##' * for `plot_pop_size(rel = FALSE)`: the absolute size of each cohort.
##' * for `plot_pop_size(rel = TRUE)`: the cohort size divided by the
##' maximum total population size (aggregated across all cohorts)
##' reached at any point in time for each region in question.
##'
##' As the returned object is a regular `ggplot` object, it can be
##' further modified with the ususal `ggplot2` syntax.
Expand All @@ -19,7 +22,7 @@
##' [popim_population()].
##' @param rel logical to indicate whether to use relative or absolute
##' population size in `plot_pop_size()`. Defaults to FALSE
##' (plotting absolute population size).
##' (plotting absolute population size).
##' @param cols vector of 2 colours to be used to generate the
##' (continuous) colour palette for plotting. Defaults to
##' `c("whitesmoke", "midnightblue")`.
Expand All @@ -42,12 +45,37 @@ NULL
##' ## update the population immunity based on the vaccination activities:
##' pop <- apply_vacc(pop, vacc)
##'
##' ## plot the population immunity by age and time:
##' plot_immunity(pop)
##'
##' ## adding some population size manually:
##' ## adding some population size manually:
##' pop$pop_size <- pop$cohort - 1990
##'
##' ## plot the population size by age and time:
##' plot_pop_size(pop)
##'
##' ## plot the population immunity by age and time:
##' ##-----------------------------------------------------------------------
##' ## setting up a population with multiple regions:
##' pop <- popim_population(region = c("A", "B"),
##' year_min = 2000, year_max = 2005,
##' age_min = 0, age_max = 10)
##' pop$pop_size <- pop$cohort - 1990
##' pop$pop_size[pop$region == "A"] <- 5 * pop$pop_size[pop$region == "A"]
##'
##' ## adding some vaccination activities:
##' vacc <- popim_vacc_activities(region = c("A", "A", "B"),
##' year = c(2001, 2002, 2003),
##' age_first = c(0,0,0), age_last = c(0,0,10),
##' coverage = 0.8, doses = NA,
##' targeting = "random")
##' pop <- apply_vacc(pop, vacc)
##'
##' plot_immunity(pop)
##'
##' plot_pop_size(pop)
##' plot_pop_size(pop, rel = TRUE)
##'
plot_immunity <- function(pop, cols = c("whitesmoke", "midnightblue")) {

assert_population(pop)
Expand Down
32 changes: 30 additions & 2 deletions man/plotting.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98fdddb

Please sign in to comment.