library(plyr) library(tidyverse) library(gridExtra) library(cowplot) library(data.table) #source("CI-Functions.R") source("CI-Functions-Bonferroni.R") defaultpath <- dirname(rstudioapi::getActiveDocumentContext()$path) setwd(defaultpath) # ALL TASKS path <- "plots/5_all_tasks_learning/raw/" plots <- list() vis_all <- c('storylines', "paohvis") vis_names <- c("HSL", "PAOH") metrics <- c('time', 'error') metrics_colors <- c('dodgerblue2', 'darkorange3') task <- 'all' task_name <- 'all' xmin <- c(0, 0) xmax <- c(150, 25) xmin_diff <- c(-50, -10) xmax_diff <- c(10, 15) v <- 1 m <- 2 for (v in 1:2) { vis = vis_all[v] vis_name <- vis_names[v] metrics_plots <-list() ## PLOT LABEL df_label <- data.frame( x = c(0), y = c(0), text = c(task_name) ) metrics_plots[[1]] <- ggplot(df_label, aes(x, y)) + geom_text(aes(label = vis_name), size=7) + ylim(0, 0) + theme_void() for (m in 1:2) { metric <- metrics[m] # READ METRIC filename_metric <- paste0(path,'printed_phase_', metric, '_means_task_', task, '_', vis,'.txt', sep='') printed_metric <- read.table(filename_metric, header = T, sep = ',') colnames(printed_metric)[colnames(printed_metric)=="upperBound_CI."] <- "upperBound_CI" filename_metricdiff <- paste0(path,'printed_phase_', metric,'_diffs_task_', task, '_', vis, '.txt', sep='') printed_metricdiff <- read.table(filename_metricdiff, header = T, sep = ',') # PLOT METRIC analysisData <- c() analysisData$name <- printed_metric$phase analysisData$pointEstimate <- printed_metric$mean_metric analysisData$ci.max <- printed_metric$upperBound_CI analysisData$ci.min <- printed_metric$lowerBound_CI plot_metric <- barChart(printed_metric, analysisData$name, nbTechs = 2, ymin = xmin[[m]], ymax = xmax[[m]], "", "", mycolor=metrics_colors[m]) metrics_plots[[m*2]] <- plot_metric ## METRIC DIFF analysisData <- c() analysisData$name <- printed_metricdiff$phase analysisData$pointEstimate <- printed_metricdiff$mean_metric analysisData$ci.max <- printed_metricdiff$upperBound_CI analysisData$ci.min <- printed_metricdiff$lowerBound_CI analysisData$level <- printed_metricdiff$corrected_CI analysisData$ci_corr.max <- printed_metricdiff$upperBound_CI_corr analysisData$ci_corr.min <- printed_metricdiff$lowerBound_CI_corr plot_diff <- barChart(printed_metricdiff, analysisData$name, nbTechs = 1, ymin = xmin_diff[[m]], ymax = xmax_diff[[m]], "", "", mycolor=metrics_colors[m]) metrics_plots[[(m * 2) + 1]] <- plot_diff } this_grid <- plot_grid( # label plot_grid(metrics_plots[[1]], ncol = 1), # + theme(plot.background = element_rect(color = "black")), # time plot_grid(metrics_plots[[2]], metrics_plots[[3]], ncol = 2, rel_widths =c(3, 3)) + theme(plot.background = element_rect(color = "#999999")), # ERROR plot_grid(metrics_plots[[4]], metrics_plots[[5]], ncol = 2, rel_widths =c(3, 3)) + theme(plot.background = element_rect(color = "#999999")), # config nrow = 3, rel_heights =c(1, 5, 5) #ncol = 3, #rel_widths =c(1, 5, 5) ) plots[[v]] <-this_grid } titles <- list() titles[[1]] <- NULL i <- 2 metrics_names <- c('Completion Time', 'Error Rate') for (metric in metrics_names) { t <- ggdraw() + draw_label(metric, x = 0.6, size = 20) titles[[i]] <- t i <- i + 1 } plots[[3]] <- cowplot::plot_grid(plotlist = titles, nrow = 3, rel_heights = c(1, 5, 5)) final_grid <- plot_grid(plots[[3]], plots[[1]], plots[[2]], # config ncol = 3, rel_widths = c(2, 5, 5) ) margin = theme(plot.margin = unit(c(2,2,2,2), "cm")) filename <- "plots/5_all_tasks_learning/time_error_all_tasks_per_phase.pdf" ggsave(filename = filename, final_grid, device = "pdf", width=18, height=4)