plot_factory | R Documentation |
This function returns a large set of typical plots in a list object. These can then be printed to a file or included in an R Markdown document.
plot_factory(
mse_list,
pm,
scenario_df,
mp_ref,
mp_sat,
mp_not_sat,
mp_not_sat2 = mp_not_sat,
custom_pal = NULL,
eg_scenario = scenario_df$scenario[1],
tradeoff = pm[1:2],
catch_breaks = NULL,
catch_labels = catch_breaks,
catch_ylim = NULL,
dodge = 0.8,
satisficed_criteria = NULL,
skip_projections = FALSE,
omit_index_fn = function(x) NULL,
survey_type = c("Ind", "AddInd"),
skip_worms = FALSE,
french = isTRUE(getOption("french"))
)
mse_list |
A list of MSEtool MSE objects representing different scenarios. The list should be named with the scenario names. |
pm |
A character vector of performance metrics. These performance metrics should exist in the current workspace or via an attached package such as MSEtool. |
scenario_df |
A data frame with the columns |
mp_ref |
Reference MPs. |
mp_sat |
A character vector of satisficed management procedures (MPs). |
mp_not_sat |
MPs that were not satisfied (a giant projection plot will
be made with these) for |
mp_not_sat2 |
MPs that were not satisfied to highlight in a projection
plot for |
custom_pal |
A named character vector of colors for the MPs. Names should correspond to the MP names. Should include all satisficed and reference MPs. |
eg_scenario |
An example scenario (as character) that will be used for the projection plot of not-satisficed MPs. |
tradeoff |
Character vector of length 2 of tradeoff PMs. |
catch_breaks |
An optional numeric vector of y-axis breaks for the catch projection panels. |
catch_labels |
An optional numeric vector of y-axis labels for the catch projection panels. This can be useful, for example, if you want the labels to be in 1000 t insead of t. |
catch_ylim |
Optional y-axis limits for catch, e.g. c(0, 100) |
dodge |
The dodge width for |
satisficed_criteria |
A named numeric vector designating the satisficed
criteria for use in a 'tigure' plot. See |
skip_projections |
Logical: skip the projection and worm plots for speed? |
omit_index_fn |
A function that indexes years in the projection period to
omit from the plot. See |
survey_type |
Which survey to plot. Passed to |
skip_worms |
Skip the worms plot? |
french |
French? |
A named list object containing the ggplot objects.
# Fake but fast example follows:
# In reality, you might get here with something like:
# mse <- lapply(om_list, runMSE, MPs = mps)
# or
# mse <- purrr::map(om_list, runMSE, MPs = mps)
library(DLMtool)
# Instead, let's use the same example thrice:
mse <- list()
mse[[1]] <- mse_example
mse[[2]] <- mse_example
mse[[3]] <- mse_example
names(mse) <- c("sc1", "sc2", "sc3")
# Use more meaningful names than this:
scenario_df <- tibble::tribble(
~scenario, ~scenario_human, ~scenario_type,
"sc1", "Scenario 1", "Reference",
"sc2", "Scenario 2", "Reference",
"sc3", "Scenario 3", "Robustness"
)
`LT LRP` <- ggmse::pm_factory("SBMSY", 0.4, c(36, 50))
`LT USR` <- ggmse::pm_factory("SBMSY", 0.8, c(36, 50))
STC <- ggmse::pm_factory("LTY", 0.5, c(1, 10))
LTC <- ggmse::pm_factory("LTY", 0.5, c(36, 50))
pm <- c("LT LRP", "LT USR", "STC", "LTC")
custom_pal <- c(RColorBrewer::brewer.pal(3, "Dark2"), "grey60")
names(custom_pal) <- c("CC1.0", "Itarget1", "Iratio2", "FMSYref75")
plots <- plot_factory(
mse,
pm = pm,
scenario_df = scenario_df,
mp_sat = c("Itarget1", "Iratio2", "FMSYref75"),
mp_ref = c("FMSYref75"),
mp_not_sat = c("CC1.0"),
custom_pal = custom_pal,
eg_scenario = "sc1",
tradeoff = c("LT LRP", "STC"),
satisficed_criteria = c("LT LRP" = 0.9, "STC" = 0.8)
)
names(plots)
plots$tigure_minimum
plots$convergence
plots$tigure_refset_avg
plots$tigure_refset
plots$worms_proj
plots$parallel_refset
plots$dot_refset
plots$radar_refset
plots$lollipops_refset
plots$projections$sc1
plots$projections_not_sat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.