mrc-ide / epireview

https://mrc-ide.github.io/epireview/
Other
26 stars 2 forks source link

Updating default color palettes and adding custom_palette() #114

Closed shaziaruybal closed 2 weeks ago

shaziaruybal commented 1 month ago

Pull Request

This PR responds to #20 and updates the default color palette to a hopefully nicer one from ggsci. It also fixes a bug (see 8a2d5bbe3fe56bee407ad056e746edce90fe450f and 193f172f8123e6eec4e3d1a8723445360011ee9f).

Additional changes:

Example usage of custom_palette():

p <- load_epidata("ebola")[["params"]]

# The default palette will only work for individual country labels, i.e. n=7 countries
forest_plot_incubation_period(p, col_by = "population_country")

# Use the custom_palette() to color all country labels, including 'multi-country' labels. In this example there are n=11 labels. 
labels <- c("DRC", "Guinea, Liberia, Sierra Leone", "Liberia, Nigeria", "Sudan", "DRC, Sudan", "Guinea, Sierra Leone", "Nigeria", "Uganda", "Guinea", "Liberia", "Sierra Leone")
colors <- c("indianred", "cornflowerblue", "forestgreen", "goldenrod", "magenta4", "turquoise4","black", "gold4", "skyblue1", "pink3", "darkgrey")

# Create the custom palette
custom_pal <- custom_palette(labels, colors)

# Plot with the custom_pal
forest_plot_incubation_period(p, col_by = "population_country",
                              col_palette = custom_pal)`

# Alternatively, use the function directly
forest_plot_incubation_period(p, col_by = "population_country",
                              col_palette = custom_palette(labels, colors))

Checklist:

shaziaruybal commented 1 month ago

@tristan-myles just took a peek at the conflicts, I think the error message may need to also be updated for custom_palette() to be in line with cli_()

shaziaruybal commented 2 weeks ago

In addition to my two comments on the files changed:

  1. devtools::check is failing because load-filter-view-epidata.Rmd no longer compiles due to the changes in forest_plot.R. Could you check the functions used in this vignette. I think you just need to provide custom palettes? Additionally, to confirm, is this the expected behaviour when now custom palette is provided?
  2. I've bumped the version to 1.3.4 based on the anticipated merge of Sangeeta's PR, can you just add a brief description of the changes introduced in this PR in the NEWS.md file. A brief one-liner is fine. :)

we fixed a minor bug when newest version of develop branch was merged and now builds - have added description to NEWS.md