diff --git a/R/results-parse.R b/R/results-parse.R index b58accca2f335958a7bf184ad83a351187ec7dbd..83fcbfe2a853d1c6bde81e15f17146a954240976 100644 --- a/R/results-parse.R +++ b/R/results-parse.R @@ -130,18 +130,23 @@ plot_models <- function(sims = baseline_sim, pivot_longer(-c(time, experiment), names_to = "compartment", values_to = "count") - - # Filter compartments - comp_plot <- setdiff(comps, comp_remove) - plot_df <- plot_df %>% filter(compartment %in% c(comp_plot)) plot_df$sim <- 'sim' plot_df$Date <- start_date + plot_df$time plot_df$time <- NULL # Add known data if(is.data.frame(known)){ - plot_df <- rbind(plot_df, known) + exps <- unique(plot_df$experiment) + for(i in exps){ + known$experiment <- i + plot_df <- rbind(plot_df, known) + } } + + # Filter compartments + comp_plot <- setdiff(comps, comp_remove) + plot_df <- plot_df %>% filter(compartment %in% c(comp_plot)) + reo_exp <- function(x) { factor(x, levels = sim_id)} @@ -159,7 +164,7 @@ plot_models <- function(sims = baseline_sim, } else ( plot_df %>% ggplot(aes(x = Date, y = count, colour = compartment, linetype = sim)) + - facet_grid(reo_exp(experiment) ~ .) + + facet_grid(reo_exp(experiment) ~ ., scale = 'free') + scale_x_date(date_breaks = "1 week", date_labels = "%m-%d") + geom_line(size = 1.5, alpha = 0.8) + scale_colour_manual(values = compcols, labels = complabels) + @@ -181,7 +186,7 @@ plot_models <- function(sims = baseline_sim, } else ( plot_df %>% ggplot(aes(x = Date, y = count+1, colour = compartment, linetype = sim)) + - facet_grid(reo_exp(experiment) ~ .) + + facet_grid(reo_exp(experiment) ~ ., scale = 'free') + scale_y_continuous(trans = trans) + scale_x_date(date_breaks = "1 week", date_labels = "%m-%d") + geom_line(size = 1.5, alpha = 0.8) +