library(plyr) library(tidyverse) library(gridExtra) library(cowplot) library(data.table) library(extrafont) loadfonts(device = "win") par(family = "LM Roman 10") #source("CI-Functions.R") source("CI-Functions-Bonferroni.R") defaultpath <- dirname(rstudioapi::getActiveDocumentContext()$path) setwd(defaultpath) path <- 'plots/per_task_mapSize/raw/' # ALL TASKS tasks <- c("A", "B", "C", "D", "E") vis_all <- c("CoordV","GlyMa", "LocSto") tasks_names <- c('Base Locations', 'Base Time', 'Distance', 'Direction', 'Adjacency') plots <- list() ## PLOT LABEL df_label <- data.frame( x = c(0), y = c(0), text = c('') ) plot_label_none <- ggplot(df_label, aes(x, y)) + geom_text(aes(label = ''), size=7) + ylim(0, 0) + theme_void() df_label <- data.frame( x = c(0), y = c(0), text = c('Glyph Maps') ) plot_label_gm <- ggplot(df_label, aes(x, y)) + geom_text(aes(label = 'Glyph Maps'), size=7) + ylim(0, 0) + theme_void() df_label <- data.frame( x = c(0), y = c(0), text = c('Coordinated Views') ) plot_label_cv <- ggplot(df_label, aes(x, y)) + geom_text(aes(label = 'Coordinated Views'), size=7) + ylim(0, 0) + theme_void() df_label <- data.frame( x = c(0), y = c(0), text = c('Location Storylines') ) plot_label_ls <- ggplot(df_label, aes(x, y)) + geom_text(aes(label = 'Location Storylines'), size=7) + ylim(0, 0) + theme_void() this_grid <-plot_grid( # label plot_label_none, ## GlyMa plot_label_gm, ## CoordView # time plot_label_cv, ## Location Storylines # time plot_label_ls, ncol = 4, rel_widths =c(1, 5, 5, 5) ) plots[[1]] <- this_grid i = 1 for (i in 1:5) { task <- tasks[i] task_name <- tasks_names[i] ## PLOT LABEL df_label <- data.frame( x = c(0), y = c(0), text = c(task_name) ) plot_label <- ggplot(df_label, aes(x, y)) + geom_text(aes(label = text), size=7) + ylim(0, 0) + theme_void() ## Glyph Maps vis <- "GlyMa" # READ TIME filename_time <- paste0(path, 'printed_phase_error_means_task_', task, "_", vis,'.txt', sep='') printed_time <- read.table(filename_time, header = T, sep = ',') colnames(printed_time)[colnames(printed_time)=="upperBound_CI."] <- "upperBound_CI" #printed_time$vis <- factor(printed_time$phase, levels=rev(levels(printed_time$phase))) filename_timediff <- paste0(path, 'printed_phase_error_diffs_task_', task, "_", vis, '.txt', sep='') printed_timediff <- read.table(filename_timediff, header = T, sep = ',') printed_timediff$phase <- factor(printed_timediff$phase, levels=c("Big-Small")) # PLOT TIME analysisData <- c() analysisData$name <- printed_time$phase analysisData$pointEstimate <- printed_time$mean_time analysisData$ci.max <- printed_time$upperBound_CI analysisData$ci.min <- printed_time$lowerBound_CI plot_time_gm <- barChart(printed_time, analysisData$name, nbTechs = 2, ymin = 0, ymax = 20, "", "", mycolor='darkorange3') ## TIME DIFF analysisData <- c() analysisData$name <- printed_timediff$phase analysisData$pointEstimate <- printed_timediff$mean_time analysisData$ci.max <- printed_timediff$upperBound_CI analysisData$ci.min <- printed_timediff$lowerBound_CI analysisData$level <- printed_timediff$corrected_CI analysisData$ci_corr.max <- printed_timediff$upperBound_CI_corr analysisData$ci_corr.min <- printed_timediff$lowerBound_CI_corr plot_timediff_gm <- barChart(printed_timediff, analysisData$name, nbTechs = 1, ymin = -25, ymax = 25, "", "", mycolor='darkorange3') ## Coordinated Views vis <- "CoordV" # READ TIME filename_time <- paste0(path, 'printed_phase_error_means_task_', task, "_", vis,'.txt', sep='') printed_time <- read.table(filename_time, header = T, sep = ',') colnames(printed_time)[colnames(printed_time)=="upperBound_CI."] <- "upperBound_CI" #printed_time$phase <- factor(printed_time$phase, levels=rev(levels(printed_time$phase))) filename_timediff <- paste0(path, 'printed_phase_error_diffs_task_', task, "_", vis, '.txt', sep='') printed_timediff <- read.table(filename_timediff, header = T, sep = ',') printed_timediff$phase <- factor(printed_timediff$phase, levels=c("Big-Small")) # PLOT TIME analysisData <- c() analysisData$name <- printed_time$phase analysisData$pointEstimate <- printed_time$mean_time analysisData$ci.max <- printed_time$upperBound_CI analysisData$ci.min <- printed_time$lowerBound_CI plot_time_cv <- barChart(printed_time, analysisData$name, nbTechs = 2, ymin = 0, ymax = 20, "", "", mycolor='darkorange3') ## TIME DIFF analysisData <- c() analysisData$name <- printed_timediff$phase analysisData$pointEstimate <- printed_timediff$mean_time analysisData$ci.max <- printed_timediff$upperBound_CI analysisData$ci.min <- printed_timediff$lowerBound_CI analysisData$level <- printed_timediff$corrected_CI analysisData$ci_corr.max <- printed_timediff$upperBound_CI_corr analysisData$ci_corr.min <- printed_timediff$lowerBound_CI_corr plot_timediff_cv <- barChart(printed_timediff, analysisData$name, nbTechs = 1, ymin = -25, ymax = 25, "", "", mycolor='darkorange3') ## Locations Storylines vis <- "LocSto" # READ TIME filename_time <- paste0(path, 'printed_phase_error_means_task_', task, "_", vis,'.txt', sep='') printed_time <- read.table(filename_time, header = T, sep = ',') colnames(printed_time)[colnames(printed_time)=="upperBound_CI."] <- "upperBound_CI" #printed_time$phase <- factor(printed_time$phase, levels=rev(levels(printed_time$phase))) filename_timediff <- paste0(path, 'printed_phase_error_diffs_task_', task, "_", vis, '.txt', sep='') printed_timediff <- read.table(filename_timediff, header = T, sep = ',') printed_timediff$phase <- factor(printed_timediff$phase, levels=c("Big-Small")) # PLOT TIME analysisData <- c() analysisData$name <- printed_time$phase analysisData$pointEstimate <- printed_time$mean_time analysisData$ci.max <- printed_time$upperBound_CI analysisData$ci.min <- printed_time$lowerBound_CI plot_time_ls <- barChart(printed_time, analysisData$name, nbTechs = 2, ymin = 0, ymax = 20, "", "", mycolor='darkorange3') ## TIME DIFF analysisData <- c() analysisData$name <- printed_timediff$phase analysisData$pointEstimate <- printed_timediff$mean_time analysisData$ci.max <- printed_timediff$upperBound_CI analysisData$ci.min <- printed_timediff$lowerBound_CI analysisData$level <- printed_timediff$corrected_CI analysisData$ci_corr.max <- printed_timediff$upperBound_CI_corr analysisData$ci_corr.min <- printed_timediff$lowerBound_CI_corr plot_timediff_ls <- barChart(printed_timediff, analysisData$name, nbTechs = 1, ymin = -25, ymax = 25, "", "", mycolor='darkorange3') this_grid <- plot_grid( # label plot_grid(plot_label, ncol = 1), # + theme(plot.background = element_rect(color = "black")), ## GlyMa plot_grid(plot_time_gm, plot_timediff_gm, ncol = 2, rel_widths =c(2, 3)) + theme(plot.background = element_rect(color = "#999999")), ## CoordView plot_grid(plot_time_cv, plot_timediff_cv, ncol = 2, rel_widths =c(2, 3)) + theme(plot.background = element_rect(color = "#999999")), ## Location Storylines plot_grid(plot_time_ls, plot_timediff_ls, ncol = 2, rel_widths =c(2, 3)) + theme(plot.background = element_rect(color = "#999999")), # config #nrow = 3, #rel_heights =c(1, 5, 5) ncol = 4, rel_widths =c(1, 5, 5, 5) ) plots[[i+1]] <- this_grid } margin = theme(plot.margin = unit(c(2,2,2,2), "cm")) p <- do.call("plot_grid", c(plots, nrow=7)) filename <- "plots/per_task_mapSize/error_per_task_mapSize.pdf" ggsave(filename = filename, p, device = "pdf", width=22, height=12)